コード例 #1
0
ファイル: VenuesManager.cs プロジェクト: zyyecho/venues
        public static string AddVenue(string loginUserInfo)
        {
            string returnStr = "";
            int newVenueID = 0;
            JObject objUser = JObject.Parse(loginUserInfo);
            try
            {
                using (venuesEntities db = new venuesEntities())
                {

                    tbl_venue tbv = new tbl_venue();
                    tbv.VenueTypeID = KeyManager.VenueTypeId_Meeting;
                    tbv.VenuePayType = "免费";
                    tbv.VenuePassword = GeneralFuction.MD5Encrypt(KeyManager.Default_Pwd);
                    tbv.VenueName = "";
                    tbv.VenueManager = "";
                    tbv.VenueLng = float.Parse("0");
                    tbv.VenueLat = float.Parse("0");
                    tbv.VenueCreateTime = DateTime.Now;
                    tbv.VenueContact = "";
                    tbv.VenueAddress = "";
                    tbv.VenueDescript = "";
                    tbv.VenueImage = "";
                    tbv.VenueStar = "";

                    tbv.Video = "";
                    tbv.LogoImg = "";
                    tbv.HomeImg ="";
                    tbv.Phone = "";
                    tbv.PostCode = "";
                    tbv.Fax = "";
                    tbv.WebSite = "" ;
                    tbv.Email = "";
                    db.AddTotbl_venue(tbv);
                    if (db.SaveChanges() != 0)
                    {
                        string strSql = "SELECT MAX(s.ID) as max FROM tbl_venue AS s";

                        ObjectQuery<DbDataRecord> resultm = db.CreateQuery<DbDataRecord>(strSql);
                        foreach (var item in resultm)
                        {
                            newVenueID = int.Parse(item["max"].ToString());
                            returnStr = item["max"].ToString();
                        }
                    }
                    else
                    {
                        returnStr = KeyManager.RetrunUnSucceed;
                    }

                }
            }
            catch (Exception e)
            {
                returnStr = e.Message;
                LogManager.addLog(KeyManager.LogTypeId_Error, KeyManager.MENUS.Menu_VenusManager, "新增场所失败,错误信息:" + e.Message, loginUserInfo);
            }

            return returnStr;
        }
コード例 #2
0
ファイル: VenuesManager.cs プロジェクト: zyyecho/venues
        public static string SaveVenues(string venueInfo, string loginUserInfo)
        {
            string returnStr = "";
            JObject objVenue = JObject.Parse(venueInfo);
            Boolean ishasVenue = false;
            JObject objUser = JObject.Parse(loginUserInfo);
            try
            {
                using (venuesEntities db = new venuesEntities())
                {
                    string strSql1 = string.Format("SELECT vv.VenueManager FROM tbl_venue AS vv WHERE vv.VenueManager='{0}'", objVenue["loginName"].ToString());
                    ObjectQuery<DbDataRecord> results = db.CreateQuery<DbDataRecord>(strSql1);
                    foreach (var ks in results)
                    {
                        ishasVenue = true;
                    }

                    if (!ishasVenue)
                    {
                        tbl_venue tbv = new tbl_venue();
                        tbv.VenueTypeID = int.Parse(objVenue["venueTypeID"].ToString());
                        tbv.VenuePayType = objVenue["payType"].ToString();
                        tbv.VenuePassword =GeneralFuction.MD5Encrypt(KeyManager.Default_Pwd);
                        tbv.VenueName = objVenue["venueName"].ToString();
                        tbv.VenueManager = objVenue["loginName"].ToString();
                        tbv.VenueLng = float.Parse(objVenue["site_Lng"].ToString());
                        tbv.VenueLat = float.Parse(objVenue["site_Lat"].ToString());
                        tbv.VenueCreateTime = DateTime.Now;
                        tbv.VenueContact = objVenue["contactPeople"].ToString();
                        tbv.VenueAddress = objVenue["address"].ToString();
                        tbv.VenueDescript = objVenue["descript"].ToString();
                        tbv.VenueImage = objVenue["smallImage"].ToString();
                        tbv.VenueStar = objVenue["star"].ToString();

                        //tbv.AverageConsumption = objVenue["AverageConsumption"].ToString();
                        //tbv.District = objVenue["District"].ToString();
                        //tbv.Country = objVenue["Country"].ToString();
                        //tbv.MeetRoomCapacity = objVenue["MeetRoomCapacity"].ToString();
                        tbv.WebSite = objVenue["WebSite"].ToString();
                        tbv.Email = objVenue["Email"].ToString();

                        db.AddTotbl_venue(tbv);

                        string otherStr=objVenue["otherAttribute"].ToString();
                        if (db.SaveChanges() != 0)
                        {
                            string strSql = "SELECT MAX(s.ID) as max FROM tbl_venue AS s";
                            int newVenueID = 0;
                            ObjectQuery<DbDataRecord> resultm = db.CreateQuery<DbDataRecord>(strSql);
                            foreach (var item in resultm)
                            {
                                newVenueID = int.Parse(item["max"].ToString());
                            }

                            if (otherStr != "[]")
                            {
                                returnStr = KeyManager.RetrunSucceed;

                                string attributeReturnStr = "";
                                JArray arrOtherVenue = JArray.Parse(objVenue["otherAttribute"].ToString());
                                foreach (JObject objOtherVenue in arrOtherVenue)
                                {
                                    attributeReturnStr = VenueAttributeManager.AddVenueAttribute(newVenueID, objOtherVenue.ToString(), loginUserInfo);
                                    if (attributeReturnStr != KeyManager.RetrunSucceed)
                                    {
                                        returnStr = attributeReturnStr;
                                        DeleteVenuesByIDs(loginUserInfo, newVenueID.ToString());//如果新增不成功,则删除刚刚插入数据表的场所信息
                                        VenueAttributeManager.DeleteVenueAttributeByVenueId(newVenueID, loginUserInfo);
                                        break;
                                    }

                                }
                            }

                            //商户:场所管理(场所信息,会议室信息),资源管理,游客管理,页面管理,页面发布(商户发布)
                            //string sysUserMenus = "" + KeyManager.MENUS.Menu_VenusManager + "," + KeyManager.MENUS.Menu_VisitorManager + "," + KeyManager.MENUS.Menu_ResourceManager + "," + KeyManager.MENUS.Menu_PagesManager + "," + KeyManager.MENUS.Menu_PagesPublishManager;
                            //AuthorityManager.EditAuthorityByUserId(KeyManager.CUR_USERID, newVenueID, sysUserMenus, KeyManager.UserTypeId_BuissiensUser);
                            returnStr = KeyManager.RetrunSucceed;
                            LogManager.addLog(KeyManager.LogTypeId_Error, KeyManager.MENUS.Menu_VenusManager, "新增场所成功,venuesinfo=" + venueInfo, loginUserInfo);

                        }
                        else
                        {
                            returnStr = KeyManager.RetrunUnSucceed;
                        }
                    }
                    else
                    {
                        returnStr = "不成功,已有登录名为“" + objVenue["loginName"].ToString() + "”的场所用户。";
                    }
                }
            }
            catch (Exception e)
            {
                returnStr = e.Message;
                LogManager.addLog(KeyManager.LogTypeId_Error, KeyManager.MENUS.Menu_VenusManager, "新增场所成功,venuesinfo=" + venueInfo + ";错误信息:" + e.Message, loginUserInfo);
            }

            return returnStr;
        }