コード例 #1
0
        public string UpdateMaterial(HttpContext context)
        {
            string strResult;
            string value = context.Request["Value"];
            int    id    = !string.IsNullOrWhiteSpace(context.Request["id"]) ? Convert.ToInt32(context.Request["id"]) : 0;

            try
            {
                using (var db = new UdowsYunPublicEntities())
                {
                    MaterialInfo mi = db.MaterialInfo.Find(id);
                    if (mi != null)
                    {
                        mi.Value = value;
                    }
                    db.SaveChanges();
                    strResult = "{ \"result\": true,\"msg\":\"修改成功!\"}";
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(strResult);
        }
コード例 #2
0
        public string SelDownMaterial(HttpContext context)
        {
            string result = "";

            try
            {
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        List <Material> list = db.Material.Where(p => p.companyId == user.CompanyId && p.IsDelete == 0).ToList();
                        if (list.Any())
                        {
                            result = JsonConvert.SerializeObject(list);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #3
0
        public string TaskManagement(HttpContext context)
        {
            string result = "";

            try
            {
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        List <PublishRule> list = db.PublishRule.Where(p => p.companyId == user.CompanyId).ToList();
                        if (list.Any())
                        {
                            result = JsonConvert.SerializeObject(list);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #4
0
        public string Select(HttpContext context)
        {
            string strResult = "";

            try
            {
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        string newsLabel = "";
                        var    n         = db.Company.Where(p => p.userId == user.id).ToList();
                        if (n.Any())
                        {
                            strResult = JsonConvert.SerializeObject(n);
                        }
                    }
                }
                else
                {
                    strResult = "";
                }
            }
            catch (DbEntityValidationException e)
            {
                LogHelper lh = new LogHelper();
                lh.WriteLog(e.EntityValidationErrors.ToString());
                strResult = "";
            }
            return(strResult);
        }
コード例 #5
0
        public string SelDownType(HttpContext context)
        {
            string result = "";

            try
            {
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        List <InfoType> list = db.InfoType.ToList();
                        if (list.Any())
                        {
                            result = JsonConvert.SerializeObject(list);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #6
0
        public string RankStatistics(HttpContext context)
        {
            string result = "";

            try
            {
                var user = RequestSession.GetSessionUser();
                pageNum  = Convert.ToInt32(context.Request["limit"]);
                PageSize = Convert.ToInt32(context.Request["page"]);
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        string         sql  = @"select * from (select row_number() over (order by id) as rn,* from (  select a.id,a.keyword as name,b.name as urlname, a.ranking as paiming,'' as returnurl from KeywordRanking a
                          left join engines b
                          on a.engineid = b.id
                          where a.companyid = " + user.CompanyId + " and ranking <> '' and ranking is not null) t ) t where rn between (" + PageSize + "-1) * " + pageNum + " + 1 and " + PageSize + " * " + pageNum;
                        List <GetTail> list = db.Database.SqlQuery <GetTail>(sql).ToList();
                        if (list.Count > 0)
                        {
                            foreach (var item in list)
                            {
                                switch (item.urlname)
                                {
                                case "百度":
                                    item.returnurl = "https://www.baidu.com/s?wd=" + item.name;
                                    break;

                                case "百度移动":
                                    item.returnurl = "https://m.baidu.com/s?word=" + item.name;
                                    break;

                                default:
                                    break;
                                }
                            }
                            result = "{\"code\":0,\"msg\":\"\",\"count\":" + db.KeywordRanking.Count(p => p.companyId == user.CompanyId && p.ranking != "" && p.ranking != null) + ",\"data\":" + JsonConvert.SerializeObject(list) + "}";
                        }
                        else
                        {
                            result = "{\"code\":0,\"msg\":\"\",\"count\":0,\"data\":\"\"}";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #7
0
        public string UpdateImage(HttpContext context)
        {
            var    user   = RequestSession.GetSessionUser();
            string result = "";

            try
            {
                var tag = context.Request["images"];
                if (user != null)
                {
                    string goodspath = ConfigurationManager.AppSettings["ImgUmasMapSrc"] + user.CompanyId + "\\";
                    string Webpath   = ConfigurationManager.AppSettings["ImgUmasWebSrc"] + user.CompanyId + "/";
                    if (!string.IsNullOrEmpty(tag))
                    {
                        string path = Base64ToImage("data:image/jpeg;base64," + tag).Replace("\\", "/");
                        user = RequestSession.GetSessionUser();
                        if (user != null)
                        {
                            using (var db = new UdowsYunPublicEntities())
                            {
                                var id = db.Company.Where(p => p.userId == user.id).ToList();
                                foreach (var vals in id)
                                {
                                    ApiSoapClient a    = new ApiSoapClient();
                                    string        json = a.UploadLicense(vals.id, ImgaeFoByte(path));
                                    ImgTag        it   = JsonConvert.DeserializeObject <ImgTag>(json);
                                    if (it != null)
                                    {
                                        if (it.result == 1)
                                        {
                                            result = "{ \"code\": 0,\"msg\": \"\",\"data\": {\"src\": \"" + Webpath + it.name + "\"}}";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        result = "{ \"code\": 1,\"msg\": \"\",\"data\": {\"src\": \"\"}}";
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper lh = new LogHelper();
                lh.WriteLog(ex.Message);
                throw;
            }
            return(result);
        }
コード例 #8
0
        public string SelInfoList(HttpContext context)
        {
            string result = "";

            try
            {
                var user = RequestSession.GetSessionUser();
                pageNum  = Convert.ToInt32(context.Request["limit"]);
                PageSize = Convert.ToInt32(context.Request["page"]);
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        string         sql  = @"select * from (select row_number() over (order by id desc) as rn,* from (select a.id,'http://pic03.uz360.cn/UmassWebPageImage/'+b.imgPath as imgPath,c.name as b2bName,a.url,CONVERT(varchar(100), DATEADD(s,a.createTime, '1970-01-01 08:00:00'), 20) as createTime,b.title,'推送成功' as Start,a.b2bId,'' as b2bUrl from SuccessInfo a 
                          left join Info b
                          on a.infoId = b.id
                          left join B2B c
                          on a.b2bId = c.id
                          where a.companyId = " + user.CompanyId + ") t ) t where rn between (" + PageSize + "-1) * " + pageNum + " + 1 and " + PageSize + " * " + pageNum;
                        List <GetInfo> list = db.Database.SqlQuery <GetInfo>(sql).ToList();
                        if (list.Count > 0)
                        {
                            ApiSoapClient a = new ApiSoapClient();
                            foreach (var val in list)
                            {
                                if (val.url.IndexOf('|') > 0)
                                {
                                    val.url = val.url.Substring(0, val.url.IndexOf('|'));
                                }
                                if (val.b2bId == 2 || val.b2bId == 3 || val.b2bId == 5 || val.b2bId == 6 || val.b2bId == 8 || val.b2bId == 10)
                                {
                                    val.b2bUrl = a.GetLoginUrl(Convert.ToInt32(user.CompanyId), val.b2bId);
                                }
                            }
                            result = "{\"code\":0,\"msg\":\"\",\"count\":" + db.SuccessInfo.Count(p => p.companyId == user.CompanyId) + ",\"data\":" + JsonConvert.SerializeObject(list) + "}";
                        }
                        else
                        {
                            result = "{\"code\":0,\"msg\":\"\",\"count\":0,\"data\":\"\"}";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #9
0
        public string AddMaterial(HttpContext context)
        {
            string strResult = "";
            string value     = context.Request["contele"];
            int    id        = !string.IsNullOrWhiteSpace(context.Request["id"]) ? Convert.ToInt32(context.Request["id"]) : 0;

            try
            {
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        int?started = db.Company.Find(user.CompanyId)?.stateId;
                        if (started == null || started != 2)
                        {
                            return("{ \"result\": false,\"msg\": \"审核没有通过!\"}");
                        }
                        int num = db.MaterialInfo.Count(p => p.M_id == id);
                        if (num < 50)
                        {
                            MaterialInfo mi = new MaterialInfo
                            {
                                M_id     = id,
                                Value    = value,
                                IsDelete = 0,
                                Start    = 1
                            };
                            db.MaterialInfo.Add(mi);
                            db.SaveChanges();
                            strResult = "{ \"result\": true,\"msg\":\"添加成功!\"}";
                        }
                        else
                        {
                            strResult = "{ \"result\": false,\"msg\":\"不可超过50条!\"}";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(strResult);
        }
コード例 #10
0
        public string SourceMaterialList(HttpContext context)
        {
            string result = "";

            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("id");
                dt.Columns.Add("Title");
                dt.Columns.Add("MNum");
                dt.Columns.Add("Num");
                var user = RequestSession.GetSessionUser();
                pageNum  = Convert.ToInt32(context.Request["limit"]);
                PageSize = Convert.ToInt32(context.Request["page"]);
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        List <Material> list = db.Material.Where(p => p.companyId == user.CompanyId && p.IsDelete == 0).OrderByDescending(p => p.id).Skip((PageSize - 1) * PageSize).Take(pageNum).ToList();
                        if (list.Any())
                        {
                            foreach (var val in list)
                            {
                                DataRow dr = dt.NewRow();
                                dr["id"]    = val.id;
                                dr["Title"] = val.title;
                                dr["MNum"]  = db.Info.Count(p => p.materialId == val.id);
                                dr["Num"]   = db.MaterialInfo.Count(p => p.M_id == val.id);
                                dt.Rows.Add(dr);
                            }
                        }
                        result = "{\"code\":0,\"msg\":\"\",\"count\":" + db.Material.Count(p => p.companyId == user.CompanyId) + ",\"data\":" + JsonConvert.SerializeObject(dt) + "}";
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #11
0
        public string DeleteMaterialInfo(HttpContext context)
        {
            string strReult = "";
            var    user     = RequestSession.GetSessionUser();

            if (user != null)
            {
                int id = !string.IsNullOrWhiteSpace(context.Request["id"]) ? Convert.ToInt32(context.Request["id"]) : 0;
                using (var db = new UdowsYunPublicEntities())
                {
                    MaterialInfo mi = db.MaterialInfo.Find(id);
                    mi.IsDelete     = 1;
                    mi.DeleteTime   = DateTimeHelper.ConvertDateTimeInt(DateTime.Now);
                    mi.DeletePerson = user.CompanyId.ToString();
                    db.SaveChanges();
                    strReult = "{ \"result\": true,\"msg\":\"删除成功!\"}";
                }
            }
            return(strReult);
        }
コード例 #12
0
        public string SelInfoEdit(HttpContext context)
        {
            string result = "";

            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("id");
                dt.Columns.Add("imgPath");
                dt.Columns.Add("Title");
                dt.Columns.Add("Value");
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    int id = !string.IsNullOrWhiteSpace(context.Request["id"]) ? Convert.ToInt32(context.Request["id"]) : 0;
                    using (var db = new UdowsYunPublicEntities())
                    {
                        List <Info> list = db.Info.Where(p => p.id == id).ToList();
                        if (list.Any())
                        {
                            foreach (var val in list)
                            {
                                DataRow dr = dt.NewRow();
                                dr["id"]      = val.id;
                                dr["imgPath"] = ConfigurationManager.AppSettings["ImgUmasWebSrc"] + val.imgPath;
                                dr["Value"]   = val.html;
                                dr["Title"]   = val.title;
                                dt.Rows.Add(dr);
                            }
                        }
                        result = JsonConvert.SerializeObject(dt);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #13
0
        public string AddSourceMaterial(HttpContext context)
        {
            string strResult = "";
            string title     = context.Request["Title"];

            try
            {
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        int?started = db.Company.Find(user.CompanyId)?.stateId;
                        if (started == null || started != 2)
                        {
                            return("{ \"result\": false,\"msg\": \"审核没有通过!\"}");
                        }
                        Material mi = new Material
                        {
                            companyId    = user.CompanyId,
                            creatname    = user.username,
                            IsDelete     = 0,
                            title        = title,
                            C__creattime = DateTimeHelper.ConvertDateTimeInt(DateTime.Now)
                        };
                        db.Material.Add(mi);
                        db.SaveChanges();
                        strResult = "{ \"result\": true,\"id\":" + mi.id + ",\"msg\":\"添加成功!\"}";
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(strResult);
        }
コード例 #14
0
        public string Register(HttpContext context)
        {
            string result   = "";
            string username = context.Request["username"];
            string password = context.Request["password"];

            try
            {
                using (var db = new UdowsYunPublicEntities())
                {
                    int num = db.User.Count(p => p.username == username);
                    if (num > 0)
                    {
                        result = "{ \"result\": false,\"msg\": \"当前账号已存在!\"}";
                    }
                    else
                    {
                        User u = new User();
                        u.username   = username;
                        u.password   = password;
                        u.createTime = DateTimeHelper.ConvertDateTimeInt(DateTime.Now);
                        u.roleId     = 3;
                        u.realName   = "";
                        db.User.Add(u);
                        db.SaveChanges();
                        result = "{ \"result\": true,\"msg\": \"注册成功!\"}";
                    }
                }
            }
            catch (DbEntityValidationException e)
            {
                LogHelper lh = new LogHelper();
                lh.WriteLog(e.EntityValidationErrors.ToString());
                result = "{ \"result\": false,\"msg\": \"" + e.EntityValidationErrors + "\"}";
            }
            return(result);
        }
コード例 #15
0
        public string SelAllInfoList(HttpContext context)
        {
            string result = "";

            try
            {
                var user = RequestSession.GetSessionUser();
                pageNum  = Convert.ToInt32(context.Request["limit"]);
                PageSize = Convert.ToInt32(context.Request["page"]);
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        string            sql  = @"select * from (select row_number() over (order by id desc) as rn,* from (select a.id,a.title,b.name,CONVERT(varchar(100), DATEADD(s,a.createTime, '1970-01-01 08:00:00'), 20) as createTime from Info a
                                                 left join InfoState b
                                                 on a.stateId = b.id
                                                 where companyId = " + user.CompanyId + ") t ) t where rn between (" + PageSize + "-1) * " + pageNum + " + 1 and " + PageSize + " * " + pageNum;
                        List <GetAllInfo> list = db.Database.SqlQuery <GetAllInfo>(sql).ToList();
                        if (list.Count > 0)
                        {
                            result = "{\"code\":0,\"msg\":\"\",\"count\":" + db.Info.Count(p => p.companyId == user.CompanyId) + ",\"data\":" + JsonConvert.SerializeObject(list) + "}";
                        }
                        else
                        {
                            result = "{\"code\":0,\"msg\":\"\",\"count\":0,\"data\":\"\"}";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #16
0
        public string DeleteMaterial(HttpContext context)
        {
            string strReult = "";
            var    user     = RequestSession.GetSessionUser();

            if (user != null)
            {
                int id = !string.IsNullOrWhiteSpace(context.Request["id"]) ? Convert.ToInt32(context.Request["id"]) : 0;
                using (var db = new UdowsYunPublicEntities())
                {
                    //var Mater = from u in db.Material where u.id == id select u;
                    //db.Material.RemoveRange(Mater);
                    Material m = db.Material.Find(id);
                    m.IsDelete     = 1;
                    m.DeleteTime   = DateTimeHelper.ConvertDateTimeInt(DateTime.Now);
                    m.DeletePerson = user.CompanyId.ToString();
                    db.SaveChanges();
                    //var MaterInfo = from u in db.MaterialInfo where u.M_id == id select u;
                    //db.MaterialInfo.RemoveRange(MaterInfo);
                    List <MaterialInfo> list = db.MaterialInfo.Where(p => p.M_id == id).ToList();
                    if (list.Any())
                    {
                        foreach (var item in list)
                        {
                            MaterialInfo mi = db.MaterialInfo.Find(item.id);
                            mi.IsDelete     = 1;
                            mi.DeleteTime   = DateTimeHelper.ConvertDateTimeInt(DateTime.Now);
                            mi.DeletePerson = user.CompanyId.ToString();
                            db.SaveChanges();
                        }
                    }
                    strReult = "{ \"result\": true,\"msg\":\"删除成功!\"}";
                }
            }
            return(strReult);
        }
コード例 #17
0
        public string SelectMaterial(HttpContext context)
        {
            string result = "";
            int    id     = 0;

            if (!string.IsNullOrWhiteSpace(context.Request["id"]))
            {
                id = Convert.ToInt32(context.Request["id"]);
            }

            try
            {
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        List <MaterialInfo> list = db.MaterialInfo.Where(p => p.id == id).ToList();
                        if (list.Any())
                        {
                            result = "{ \"result\": true,\"msg\": " + JsonConvert.SerializeObject(list) + "}";
                        }
                        else
                        {
                            result = "{ \"result\": false,\"msg\": \"\"}";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #18
0
        public string Update(HttpContext context)
        {
            string strResult      = "";
            string companyName    = context.Request["companyName"];
            string shortName      = context.Request["shortName"];
            string domain         = context.Request["domain"];
            string companyAddress = context.Request["companyAddress"];
            string mainProducts   = context.Request["mainProducts"];
            string mainBrands     = context.Request["mainBrands"];
            string keywords       = context.Request["keywords"];
            string companyDesc    = context.Request["companyDesc"];
            string companyPhone   = context.Request["companyPhone"];
            string companyEmail   = context.Request["companyEmail"];
            string companyFax     = context.Request["companyFax"];

            try
            {
                if (companyAddress.Length < 7)
                {
                    return("{ \"result\": false,\"msg\": \"公司地址长度不正确!\"}");
                }
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        int?started = db.Company.Find(user.CompanyId)?.stateId;
                        if (started == 2)
                        {
                            return("{ \"result\": false,\"msg\": \"已审核通过,不可修改!\"}");
                        }
                        string newsLabel = "";
                        var    n         = db.Company.Where(p => p.userId == user.id).ToList();
                        if (!n.Any())
                        {
                            Company c = new Company
                            {
                                //用户ID
                                userId = user.id,
                                //公司名称
                                companyName = companyName,
                                //公司简称
                                shortName = shortName,
                                //域名
                                domain = domain,
                                //公司地址
                                companyAddress = companyAddress,
                                //主营产品
                                mainProducts = mainProducts,
                                //主要品牌
                                mainBrands = mainBrands,
                                //关键词
                                keywords = keywords,
                                //公司介绍
                                companyDesc = companyDesc,
                                //公司手机号
                                companyPhone = companyPhone,
                                //公司Email
                                companyEmail = companyEmail,
                                //公司传真
                                companyFax = companyFax,
                                //审核状态
                                stateId = 1,
                            };
                            c.FastDefaultStringReplace <Company>();
                            db.Company.Add(c);
                            db.SaveChanges();
                            strResult = "{ \"result\": true,\"msg\": \"修改成功!\"}";
                        }
                        else
                        {
                            foreach (var item in n)
                            {
                                //用户ID
                                item.userId = user.id;
                                //公司名称
                                item.companyName = companyName;
                                //公司简称
                                item.shortName = shortName;
                                //域名
                                item.domain = domain;
                                //公司地址
                                item.companyAddress = companyAddress;
                                //主营产品
                                item.mainProducts = mainProducts;
                                //主要品牌
                                item.mainBrands = mainBrands;
                                //关键词
                                item.keywords = keywords;
                                //公司介绍
                                item.companyDesc = companyDesc;
                                //公司手机号
                                item.companyPhone = companyPhone;
                                //公司Email
                                item.companyEmail = companyEmail;
                                //公司传真
                                item.companyFax = companyFax;
                                db.SaveChanges();
                                strResult = "{ \"result\": true,\"msg\": \"修改成功!\"}";
                            }
                        }
                    }
                }
                else
                {
                    strResult = "{ \"result\": false,\"msg\": \"登录超时,请重新登录!\"}";
                }
            }
            catch (DbEntityValidationException e)
            {
                LogHelper lh = new LogHelper();
                lh.WriteLog(e.EntityValidationErrors.ToString());
                strResult = "{ \"result\": false,\"msg\": \"" + e.EntityValidationErrors + "\"}";
            }
            return(strResult);
        }
コード例 #19
0
        public string Update(HttpContext context)
        {
            string strResult = "";
            string realName  = context.Request["realName"];
            string post      = context.Request["post"];
            string sex       = string.IsNullOrWhiteSpace(context.Request["Sexs"]) ? "男" : context.Request["Sexs"];
            string mobile    = context.Request["mobile"];
            string phone     = context.Request["phone"];
            string qq        = context.Request["qq"];
            string email     = context.Request["email"];
            string address   = context.Request["address"];
            string zip       = context.Request["zip"];

            try
            {
                if (address.Length < 7)
                {
                    return("{ \"result\": false,\"msg\": \"地址长度不正确!\"}");
                }
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        int?started = db.Company.Find(user.CompanyId)?.stateId;
                        if (started == 2)
                        {
                            return("{ \"result\": false,\"msg\": \"已审核通过,不可修改!\"}");
                        }
                        string         newsLabel = "";
                        List <Company> n         = db.Company.Where(p => p.userId == user.id).ToList();
                        if (n.Any())
                        {
                            foreach (var val in n)
                            {
                                var c = db.Company.Find(val.id);
                                c.realName = realName.Trim().Replace(" ", "");
                                c.post     = post.Trim().Replace(" ", "");
                                c.sex      = sex.Trim().Replace(" ", "");
                                c.mobile   = mobile.Trim().Replace(" ", "");
                                c.phone    = phone.Trim().Replace(" ", "");
                                c.qq       = qq.Trim().Replace(" ", "");
                                c.email    = email.Trim().Replace(" ", "");
                                c.address  = address.Trim().Replace(" ", "");
                                c.zip      = zip.Trim().Replace(" ", "");
                                c.FastDefaultStringReplace <Company>();
                            }
                            db.SaveChanges();
                            strResult = "{ \"result\": true,\"msg\": \"修改成功!\"}";
                        }
                        else
                        {
                            strResult = "{ \"result\": false,\"msg\": \"请先补充公司资料!\"}";
                        }
                    }
                }
                else
                {
                    strResult = "{ \"result\": false,\"msg\": \"登录超时,请重新登录!\"}";
                }
            }
            catch (DbEntityValidationException e)
            {
                LogHelper lh = new LogHelper();
                lh.WriteLog(e.EntityValidationErrors.ToString());
                strResult = "{ \"result\": false,\"msg\": \"" + e.EntityValidationErrors + "\"}";
            }
            return(strResult);
        }
コード例 #20
0
ファイル: login.ashx.cs プロジェクト: m18551091095/Umass
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string pagetype = context.Request["pageType"];

            switch (pagetype)
            {
            case "getUser":
            {
                //ApiSoapClient a = new ApiSoapClient();
                //string imgList = a.GetCacheList(1);
                string loginname = context.Request["loginname"];
                string loginpsw  = context.Request["loginpsw"];
                try
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        var loginuser = db.User.Where(p => p.username == loginname).ToList();
                        if (loginuser.Count > 0)
                        {
                            foreach (var val in loginuser)
                            {
                                if (loginpsw == val.password)
                                {
                                    SessionUser user = new SessionUser();
                                    user.id       = val.id;
                                    user.username = val.username;
                                    user.password = val.password;
                                    user.realName = val.realName;
                                    user.roleId   = val.roleId;
                                    var intem = db.Company.Where(p => p.userId == val.id).ToList();
                                    foreach (var iem in intem)
                                    {
                                        user.CompanyId = iem.id;
                                    }
                                    RequestSession.AddSessionUser(user);
                                    context.Response.Write("");
                                }
                                else
                                {
                                    context.Response.Write("用户密码错误!");
                                }
                            }
                        }
                        else
                        {
                            context.Response.Write("用户不存在!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper lh = new LogHelper();
                    lh.WriteLog(ex.Message.ToString());
                    context.Response.Write("数据库连接出错!");
                    throw;
                }
            }
            break;

            case "LoginOut":
                HttpContext rq = HttpContext.Current;
                rq.Session["SESSION_USER"] = null;
                context.Response.Write("{ \"result\": true,\"msg\": \"1\"}");
                break;
            }
        }
コード例 #21
0
        public string InseInfo(HttpContext context)
        {
            string strResult  = "";
            string title      = context.Request["Title"];
            string infoTypeId = context.Request["InfoTypeId"];
            string imagePath  = context.Request["ImgPath"];
            string value      = context.Request["contele"];
            int    id         = !string.IsNullOrWhiteSpace(context.Request["id"]) ? Convert.ToInt32(context.Request["id"]) : 0;

            try
            {
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        int?started = db.Company.Find(user.CompanyId)?.stateId;
                        if (started == null || started != 2)
                        {
                            return("{ \"result\": false,\"msg\": \"审核没有通过!\"}");
                        }
                        if (id == 0)
                        {
                            Info ic = new Info
                            {
                                imgPath    = imagePath,
                                createTime = DateTimeHelper.ConvertDateTimeInt(DateTime.Now),
                                title      = title,
                                typeId     = Convert.ToInt32(infoTypeId),
                                html       = value,
                                stateId    = 2,
                                companyId  = Convert.ToInt32(user.CompanyId)
                            };
                            db.Info.Add(ic);
                            db.SaveChanges();
                            strResult = "{ \"result\": true,\"msg\":\"添加成功!\"}";
                        }
                        else
                        {
                            Info ic = db.Info.Find(id);
                            if (ic != null)
                            {
                                ic.imgPath = imagePath;
                                ic.title   = title;
                                ic.typeId  = Convert.ToInt32(infoTypeId);
                                ic.html    = value;
                            }

                            db.SaveChanges();
                            strResult = "{ \"result\": true,\"msg\":\"修改成功!\"}";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(strResult);
        }
コード例 #22
0
        public string InsertInfo(HttpContext context)
        {
            string strResult    = "";
            int    mid          = Convert.ToInt32(context.Request["Mid"]);
            string infoNum      = context.Request["InfoNum"];
            string infoTypeId   = context.Request["InfoTypeId"];
            string precisewords = context.Request["precisewords"];
            string xushu        = context.Request["xushu"];
            string key1         = context.Request["key1"];
            string key2         = context.Request["key2"];
            string key3         = context.Request["key3"];
            string key4         = context.Request["key4"];
            string key5         = context.Request["key5"];
            string strImgPath   = context.Request["ImgPath"];

            try
            {
                var      user     = RequestSession.GetSessionUser();
                string   html     = "";
                string   strs     = "";
                string   strTitle = "";
                string[] str      = new string[] { };
                if (!string.IsNullOrWhiteSpace(precisewords))
                {
                    strs += precisewords + ",";
                }
                if (!string.IsNullOrWhiteSpace(xushu))
                {
                    strs += xushu + ",";
                }
                if (!string.IsNullOrWhiteSpace(key1))
                {
                    strs += key1 + ",";
                }
                if (!string.IsNullOrWhiteSpace(key2))
                {
                    strs += key2 + ",";
                }
                if (!string.IsNullOrWhiteSpace(key3))
                {
                    strs += key3 + ",";
                }
                if (!string.IsNullOrWhiteSpace(key4))
                {
                    strs += key4 + ",";
                }
                if (!string.IsNullOrWhiteSpace(key5))
                {
                    strs += key5 + ",";
                }
                if (!string.IsNullOrWhiteSpace(strs))
                {
                    strs = strs.Substring(0, strs.Length - 1);
                    str  = strs.Split(',');
                }

                if (str.Length < 5)
                {
                    return("{ \"result\": false,\"msg\":\"精确词过少且不能重复!\"}");
                }
                string[] strImg = new string[] { };
                if (!string.IsNullOrWhiteSpace(strImgPath))
                {
                    strImg = strImgPath.Split(',');
                }
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        int?started = db.Company.Find(user.CompanyId)?.stateId;
                        if (started == null || started != 2)
                        {
                            return("{ \"result\": false,\"msg\": \"审核没有通过!\"}");
                        }
                        if (db.MaterialInfo.Count(p => p.M_id == mid && p.Start == 1) < 3)
                        {
                            return("{ \"result\": false,\"msg\":\"素材过少!\"}");
                        }
                        Info ic = new Info();
                        for (int i = 0; i < Convert.ToInt32(infoNum); i++)
                        {
                            for (int j = 0; j < 3; j++)
                            {
                                MaterialInfo list = db.MaterialInfo.Where(p => p.M_id == mid && p.Start == 1 && p.IsDelete == 0).OrderBy(_ => Guid.NewGuid()).First();
                                if (list != null)
                                {
                                    html += list.Value + "<br />";
                                }
                            }
                            for (int j = 0; j < 3; j++)
                            {
                                if (str.Length > 0)
                                {
                                }
                            }
                            int num = 1;
                            while (num < 4)
                            {
                                if (num == 3)
                                {
                                    string title = strTitle.Substring(0, strTitle.Length - 1);
                                    if (db.Info.Count(p => p.title == title) <= 0)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        num      = 1;
                                        strTitle = "";
                                    }
                                }
                                else
                                {
                                    Random rnd   = new Random();
                                    int    index = rnd.Next(str.Length);
                                    if (!strTitle.Contains(str[index]))
                                    {
                                        strTitle += str[index] + "|";
                                        num++;
                                    }
                                    else
                                    {
                                        num = strTitle.Split('|').Length - 1;
                                    }
                                }
                            }
                            string imgPath = "";
                            if (strImg.Length > 0)
                            {
                                Random rd  = new Random();
                                int    ind = rd.Next(strImg.Length);
                                imgPath = strImg[ind];
                            }
                            ic.imgPath    = imgPath;
                            ic.title      = strTitle.Substring(0, strTitle.Length - 1);
                            ic.companyId  = Convert.ToInt32(user.CompanyId);
                            ic.html       = html;
                            ic.typeId     = Convert.ToInt32(infoTypeId);
                            ic.materialId = mid;
                            ic.stateId    = 2;
                            ic.createTime = DateTimeHelper.ConvertDateTimeInt(DateTime.Now);
                            db.Info.Add(ic);
                            db.SaveChanges();
                            strTitle = "";
                            html     = "";
                        }
                        strResult = "{ \"result\": true,\"msg\":\"添加成功!\"}";
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(strResult);
        }
コード例 #23
0
        public string UpdatePublishRule(HttpContext context)
        {
            string result       = "";
            int    intervalDay  = !string.IsNullOrWhiteSpace(context.Request["intervalDay"]) ? Convert.ToInt32(context.Request["intervalDay"]) : 0;
            int    publishCount = !string.IsNullOrWhiteSpace(context.Request["publishCount"]) ? Convert.ToInt32(context.Request["publishCount"]) : 0;

            try
            {
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        int?started = db.Company.Find(user.CompanyId)?.stateId;
                        if (started == null || started != 2)
                        {
                            return("{ \"result\": false,\"msg\": \"审核没有通过!\"}");
                        }
                        List <PublishRule> list = db.PublishRule.Where(p => p.companyId == user.CompanyId).ToList();
                        if (list.Any())
                        {
                            foreach (var item in list)
                            {
                                PublishRule pr = db.PublishRule.Find(item.id);
                                if (intervalDay != 0)
                                {
                                    pr.intervalDay = intervalDay;
                                }
                                if (publishCount != 0)
                                {
                                    pr.publishCount = publishCount;
                                }
                                db.SaveChanges();
                                result = "{ \"result\": true,\"msg\":\"修改成功!\"}";
                            }
                        }
                        else
                        {
                            PublishRule pr = new PublishRule();
                            if (intervalDay != 0)
                            {
                                pr.intervalDay = intervalDay;
                            }
                            if (publishCount != 0)
                            {
                                pr.publishCount = publishCount;
                            }
                            pr.companyId = Convert.ToInt32(user.CompanyId);
                            pr.startDate = DateTimeHelper.ConvertDateTimeInt(DateTime.Now);
                            db.PublishRule.Add(pr);
                            db.SaveChanges();
                            result = "{ \"result\": true,\"msg\":\"添加成功!\"}";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }
コード例 #24
0
        public string Index(HttpContext context)
        {
            string result = "";
            string sql;

            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("id");
                dt.Columns.Add("Name");
                dt.Columns.Add("Data");
                var user = RequestSession.GetSessionUser();
                if (user != null)
                {
                    using (var db = new UdowsYunPublicEntities())
                    {
                        sql = "select * from Company_51sole where companyId=" + user.CompanyId;
                        int sole = db.Database.SqlQuery <Company_51sole>(sql).Count();
                        if (sole > 0)
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "51Sole";
                            dr["Data"] = "是";
                            dt.Rows.Add(dr);
                        }
                        else
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "51Sole";
                            dr["Data"] = "否";
                            dt.Rows.Add(dr);
                        }
                        sql = "select * from Company_99inf where companyId=" + user.CompanyId;
                        int inf = db.Database.SqlQuery <Company_99inf>(sql).Count();
                        if (inf > 0)
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "久久信息";
                            dr["Data"] = "是";
                            dt.Rows.Add(dr);
                        }
                        else
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "久久信息";
                            dr["Data"] = "否";
                            dt.Rows.Add(dr);
                        }
                        sql = "select * from Company_atobo where companyId=" + user.CompanyId;
                        int atobo = db.Database.SqlQuery <Company_atobo>(sql).Count();
                        if (atobo > 0)
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "阿土伯";
                            dr["Data"] = "是";
                            dt.Rows.Add(dr);
                        }
                        else
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "阿土伯";
                            dr["Data"] = "否";
                            dt.Rows.Add(dr);
                        }
                        sql = "select * from Company_b2b168 where companyNo=" + user.CompanyId;
                        int b2b = db.Database.SqlQuery <Company_b2b168>(sql).Count();
                        if (b2b > 0)
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "八方资源";
                            dr["Data"] = "是";
                            dt.Rows.Add(dr);
                        }
                        else
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "八方资源";
                            dr["Data"] = "否";
                            dt.Rows.Add(dr);
                        }
                        sql = "select * from Company_gtobal where companyNo=" + user.CompanyId;
                        int gtobal = db.Database.SqlQuery <Company_gtobal>(sql).Count();
                        if (gtobal > 0)
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "际通宝";
                            dr["Data"] = "是";
                            dt.Rows.Add(dr);
                        }
                        else
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "际通宝";
                            dr["Data"] = "否";
                            dt.Rows.Add(dr);
                        }
                        sql = "select * from Company_jqw where companyId=" + user.CompanyId;
                        int jqw = db.Database.SqlQuery <Company_jqw>(sql).Count();
                        if (jqw > 0)
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "金泉网";
                            dr["Data"] = "是";
                            dt.Rows.Add(dr);
                        }
                        else
                        {
                            DataRow dr = dt.NewRow();
                            dr["id"]   = user.id;
                            dr["Name"] = "金泉网";
                            dr["Data"] = "否";
                            dt.Rows.Add(dr);
                        }
                    }
                }
                result = "{\"code\":0,\"msg\":\"\",\"count\":6,\"data\":" + JsonConvert.SerializeObject(dt) + "}";
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(result);
        }