Пример #1
0
 // 일반 멤버 추가
 public bool MemberInsertToDB(MemberModel memItem)
 {
     try
     {
         // DB를 새로 연다.
         conn = db.DbOpen();
         //열려 있으면 사용한다.
         if (conn.State.ToString() != "Open")
         {
             conn.Open();
         }
         else
         {
             // 고유아이디/이름/나이/성별/중성화상태/사진/상태메모
             string query = "INSERT INTO dbo.Member (memName,memPassword,memAddress,memEmail,memPhone) VALUES (@memName,@memPassword,@memAddress,@memEmail,@memPhone)";
             SqlCommand sqlQuery = new SqlCommand(query, conn);
             sqlQuery.Parameters.AddWithValue("@memName", memItem.memName);
             sqlQuery.Parameters.AddWithValue("@memPassword", memItem.memPassword);
             sqlQuery.Parameters.AddWithValue("@memAddress", memItem.memAddress);
             sqlQuery.Parameters.AddWithValue("@memEmail", memItem.memEmail);
             sqlQuery.Parameters.AddWithValue("@memPhone", memItem.memPhone);
             // 실행
             int rows = sqlQuery.ExecuteNonQuery();
         }
         db.DbClose();
         return true;
     }
     catch (SqlException sqlEx)
     {
         sqlEx.Message.ToString();
         return false;
     }
 }
Пример #2
0
        public static string CallParametersString(MemberModel member)
        {
            string template = GetTemplate("FunctionParameter");
            string res = "";
            if (member.Parameters != null && member.Parameters.Count > 0)
            {
                for (int i = 0; i < member.Parameters.Count; i++)
                {
                    MemberModel param = member.Parameters[i];
                    string one = template;

                    if (i + 1 < member.Parameters.Count)
                        one = ReplaceTemplateVariable(one, "PComma", ",");
                    else
                        one = ReplaceTemplateVariable(one, "PComma", null);

                    one = ReplaceTemplateVariable(one, "PName", param.Name);

                    one = ReplaceTemplateVariable(one, "PType", null);
                    one = ReplaceTemplateVariable(one, "PDefaultValue", null);

                    res += one;
                }
            }
            return res;
        }
Пример #3
0
        public static string ToDeclarationString(MemberModel m, string template)
        {
            // Insert Name
            if (m.Name != null)
                template = ReplaceTemplateVariable(template, "Name", m.Name);
            else
                template = ReplaceTemplateVariable(template, "Name", null);

            // If method, insert arguments
            template = ReplaceTemplateVariable(template, "Arguments", ParametersString(m, true));

            if (!string.IsNullOrEmpty(m.Type))
            {
                if ((m.Flags & FlagType.Setter) > 0 && m.Parameters != null && m.Parameters.Count == 1)
                    template = ReplaceTemplateVariable(template, "Type", FormatType(m.Parameters[0].Type));
                else
                    template = ReplaceTemplateVariable(template, "Type", FormatType(m.Type));
            }
            else
                template = ReplaceTemplateVariable(template, "Type", null);

            if (m.Value != null)
                template = ReplaceTemplateVariable(template, "Value", m.Value);
            else
                template = ReplaceTemplateVariable(template, "Value", null);

            return template;
        }
        public static requirement ToRequirement(this NewServeEventModel._RequirementModel model, MemberModel member)
        {
            if (model == null) return null;

            var entity = new requirement
            {
                ID = model.ID,
                IsPrivate = model.IsPrivate,
                MemberID = member.MemberID,
                MemberName = member.MemberName,
                RequirementTypeName = model.RequirementTypeName,
                Status = model.Status,
                Title = model.Title,
                Description = model.Description,

            };

            if (member.DefaultGroup != null)
            {
                entity.GroupID = member.DefaultGroup.GroupID;
                entity.GroupName = member.DefaultGroup.GroupName;
            }

            return entity;
        }
        public static RequirementDetailModel ToRequirementDetailModel(this requirement entity, MemberModel member, GroupModel group)
        {
            if (entity == null) return null;

            var model = new RequirementDetailModel()
            {
                Description = entity.Description,
                GroupID = entity.GroupID,
                GroupName = entity.GroupName,
                ID = entity.ID,
                IsPrivate = entity.IsPrivate,
                MemberID = entity.MemberID,
                MemberName = entity.MemberName,
                RequirementTypeName = entity.RequirementTypeName,
                Title = entity.Title,
                EndDate = entity.EndDate,
                StartDate = entity.StartDate,
                Remark = entity.Remark,
                Member = member,
                Group = group,
                Status = entity.Status
            };

            return model;
        }
Пример #6
0
        public TextParameters(MemberModel member)
        {
            this.text = member.ToString();

            //if(member.Comments!=null)
            //this.comments = member.Comments.Split('@');
            this.comments = member.Comments;
        }
Пример #7
0
 public static string GetStaticExternOverride(MemberModel member)
 {
     FlagType ft = member.Flags;
     string modifiers = "";
     if ((ft & FlagType.Extern) > 0)
         modifiers += "extern ";
     if ((ft & FlagType.Static) > 0)
         modifiers += "static ";
     if ((ft & FlagType.Override) > 0)
         modifiers += "override ";
     return modifiers;
 }
Пример #8
0
 public static string GetTipDetails(MemberModel member, string highlightParam)
 {
     try
     {
         string tip = (UITools.Manager.ShowDetails) ? GetTipFullDetails(member, highlightParam) : GetTipShortDetails(member, highlightParam);
         // remove paragraphs from comments
         return RemoveHTMLTags(tip);
     }
     catch(Exception ex)
     {
         ErrorManager.ShowError(/*"Error while parsing comments.\n"+ex.Message,*/ ex);
         return "";
     }
 }
Пример #9
0
 public static string GetModifiers(MemberModel member)
 {
     string modifiers = "";
     Visibility acc = member.Access;
     if ((acc & Visibility.Private) > 0)
         modifiers += "private ";
     else if ((acc & Visibility.Public) > 0)
         modifiers += "public ";
     else if ((acc & Visibility.Protected) > 0)
         modifiers += "protected ";
     else if ((acc & Visibility.Internal) > 0)
         modifiers += "internal ";
     return modifiers;
 }
Пример #10
0
 public ActionResult DoConfirm()
 {
     MemberModel member = new MemberModel();
     member = WebUtil.Eval<MemberModel>(member, "", "");
     member.setPk(member.createPk());
     JsResultObject re=BaseZdBiz.Save(member);
     if (re.code == JsResultObject.CODE_SUCCESS)
     {
         bool isSended = EMailUtil.SendMail("捷达商旅会员信息确认", "会员号", new string[] { member.email });
         ViewData[typeof(MemberModel).Name] = member;
         return View("RequestVaildate");
     }
     else {
         return View("Error");
     }
 }
Пример #11
0
 private void btnRead_Click(object sender, EventArgs e)
 {
     MemberClient client = new MemberClient("BasicHttpBinding_IMember", WCFServiceUrl.MemberServiceUrl);
     Member = client.GetMemberInfo(txtMemCardIDorMobile.Text);
     if (Member != null)
     {
         lblMC_Name.Text = Member.MC_Name;
         lblCL_Name.Text = Member.CL_LevelName;
         lblMC_Point.Text = Member.MC_Point.ToString();
         lblMC_TotalMoney.Text = Member.MC_TotalMoney.ToString();
     }
     else
     {
         MessageBox.Show("您输入的会员卡号/手机不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #12
0
        public static int CreateMember(string userName, string firstName,
                                       string lastName, int phone_num)
        {
            int id = UserProcessor.get_id(userName);

            MemberModel data = new MemberModel
            {
                FirstName = firstName,
                LastName  = lastName,
                Phone_Num = phone_num,
                User_ID   = id
            };

            string sql = @"insert into dbo.Member(FirstName, LastName, Phone, User_ID)
                        values (@FirstName, @LastName, @Phone_num, @User_ID);";

            return(SqlDataAccess.SaveData <MemberModel>(sql, data));
        }
        public static MemberModel MapToMemberModel(Member memberDataBase, AccessControlSystemEntities context)
        {
            MemberModel memberModel = new MemberModel();

            memberModel.Id          = memberDataBase.Id;
            memberModel.CardNumber  = memberDataBase.CardNumber;
            memberModel.Title       = memberDataBase.Title;
            memberModel.FirstName   = memberDataBase.FirstName;
            memberModel.LastName    = memberDataBase.LastName;
            memberModel.CompanyName = (from x in context.Members
                                       where x.Id == memberModel.Id
                                       from y in context.Companies
                                       where y.Id == x.CompanyId
                                       select y.Name
                                       ).FirstOrDefault();

            return(memberModel);
        }
Пример #14
0
 private Corresponcence GetCorrespondenceByMember(MemberModel member)
 {
     return(new Corresponcence()
     {
         ID = Guid.NewGuid(),
         Date = DateTime.Now,
         OwnerID = member.Member.ID,
         OwnerType = "Membership",
         EmailType = "Email",
         Message = _selectedMailTemplate != null?ParseMailMessage(member) : Message,
                       Subject = Correspondence.Subject,
                       FromAddress = Correspondence.FromAddress,
                       ToAddress = member.Contact.Email,
                       UserID = AccessService.Current.User.ID,
                       CorresponcenceType = Correspondence.CorresponcenceType,
                       EmailHeader = Correspondence.EmailHeader
     });
 }
Пример #15
0
        public static TypeDefinitionKind Parse(string comment, MemberModel model, bool detectKindOnly)
        {
            if (model != null && !string.IsNullOrEmpty(comment))
            {
                switch (model.Type)
                {
                    case "Array":
                        return ParseTypedArray(comment, model, detectKindOnly);

                    case "Function":
                        return ParseTypedCallback(comment, model, detectKindOnly);
                }

                if (model.Type == ObjectType) 
                    return ParseTypedObject(comment, model, detectKindOnly);
            }
            return TypeDefinitionKind.Null;
        }
Пример #16
0
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        OrdersModel orders = (OrdersModel)e.Item.DataItem;

        MemberModel member   = bll_member.GetModel(orders.MemberId.ToString());
        string      username = "******";

        if (member != null)
        {
            username = member.Username + " ( " + member.Realname + " )";
        }

        ((HtmlTableCell)e.Item.FindControl("Eval_Member")).InnerHtml     = username;
        ((HtmlTableCell)e.Item.FindControl("Eval_PayWay")).InnerText     = XMLHelper.GetXmlDataVal(orders.PayWay.ToString(), "PayWay");
        ((HtmlTableCell)e.Item.FindControl("Eval_Price")).InnerText      = orders.Price.ToString("C0", nfi);
        ((HtmlTableCell)e.Item.FindControl("Eval_Status")).InnerHtml     = bll_orders.GetStatus(orders, "stat");
        ((HtmlTableCell)e.Item.FindControl("Eval_CreateTime")).InnerText = DateHelper.ToShortDate(orders.CreateTime);
    }
Пример #17
0
        public ActionResult SaveMember(MemberModel model)
        {
            var message = "message";
            var result  = "result";

            model.CreatedByUserId = ActiveUser.UserId;
            result = _memberManager.SaveMember(model);
            if (model != null && ModelState.IsValid)
            {
                message = result;
            }
            else
            {
                message = ModelState.ModelErrors();
            }

            return(Json(new { message = message, result = result }));
        }
Пример #18
0
        //GET
        public ActionResult RemoveMember(string id, string application)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id", "No initiative id provided.");
            }

            var initiative = GetInitiativeViewModel(id);

            var model = new MemberModel
            {
                DeveloperName              = initiative.DeveloperRoles.Single(x => x.DeveloperName == application).DeveloperName,
                InitiativeName             = initiative.Name,
                UniqueInitiativeIdentifier = id,
            };

            return(View(model));
        }
Пример #19
0
        /// <summary>
        /// Check if a type is already in the file's imports
        /// Throws an Exception if the type name is ambiguous
        /// (ie. same name as an existing import located in another package)
        /// </summary>
        /// <param name="member">Element to search in imports</param>
        /// <param name="atLine">Position in the file</param>
        public override bool IsImported(MemberModel member, int atLine)
        {
            if (member == ClassModel.VoidClass)
            {
                return(false);
            }
            FileModel cFile = Context.CurrentModel;
            // same package is auto-imported
            string package = member.Type.Length > member.Name.Length
                ? member.Type.Substring(0, member.Type.Length - member.Name.Length - 1)
                : "";

            if (package == cFile.Package)
            {
                return(true);
            }
            return(base.IsImported(member, atLine));
        }
Пример #20
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            String userName = txtTenDN.Text.Trim();
            String password = txtMatKhau.Text.Trim();

            MemberModel memberModel = MemberDAO.getAdminByUserNameNPass(userName, password);

            if (memberModel != null)
            {
                Constants.USER_LOGIN = memberModel;
                this.Hide();
                new FormMain().Show();
            }
            else
            {
                MessageBox.Show(this, "Đăng Nhập Thất Bại !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public static serveeventfeedback ToServeEventFeedback(this NewServeEventModel._FeedbackModel model, int eventID, MemberModel target)
        {
            if (model == null) return null;

            var entity = new serveeventfeedback()
            {
                Feedback = model.Feedback,
                FromMemberID = model.FromMemberID,
                FromMemberName = model.From,
                ID = model.FeedbackID,
                TargetMemberID = target.MemberID,
                TargetMemberName = target.MemberName
            };

            entity.ServeEventID = eventID;

            return entity;
        }
Пример #22
0
        /// <summary>
        /// 设置职员信息
        /// </summary>
        /// <param name="model"></param>
        public static void SetMember(MemberEntity model)
        {
            if (VerifyHelper.IsNull(model))
            {
                return;
            }

            MemberModel meModel = new MemberModel();

            meModel.MemberId    = StringHelper.Get(model.Id);
            meModel.MemeberType = EnumMemberType.登录会员;
            meModel.Account     = model.Account;
            meModel.NameTag     = model.NameTag;
            meModel.Password    = model.Password;
            meModel.LastLoginIP = model.LastLoginIP;
            meModel.LastLoginDt = model.LastLoginDt;
            SetMember(meModel);
        }
Пример #23
0
        public void InsertMember()
        {
            MemberModel memberModel = new MemberModel
            {
                IDMember    = Guid.NewGuid(),
                Description = "description1",
                Name        = "name1",
                Position    = "phd1",
                Resume      = string.Empty,
                Title       = "title1"
            };

            memberRepository.InsertMember(memberModel);

            Member dbMember = dbContext.Members.FirstOrDefault(x => x.IDMember == memberModel.IDMember);

            Assert.IsNotNull(dbMember);
        }
        public void SendInsert(MemberModel model)
        {
            var message = new AddMemberMessage();

            message.ID          = model.ID;
            message.FullName    = model.FullName;
            message.Source      = model.Source;
            message.Age         = model.Age;
            message.CellNumber  = model.CellNumber;
            message.DateOfBirth = model.DateOfBirth;
            message.LegacyID    = model.ID;
            message.RequestId   = model.RequestId;
            message.Code        = MemberEvents.Create;
            message.RequestDate = model.RequestDate;
            message.Version     = model.Version;

            _producer.Send(1, JsonConvert.SerializeObject(message));
        }
Пример #25
0
        public async Task <List <ItemModel> > GetCharacterEquippedAsync(MemberModel member, CharacterModel character)
        {
            string path  = "Destiny2/" + member.MemberType.ToString() + "/Profile/" + member.MemberID;
            string query = "/Character/" + character.Id + "/?components=205";

            accessor.CreateUri(path, query);

            string response = await APIAccessor.RequestAsync(APIAccessor.ApiClient);

            var result = JsonConvert.DeserializeObject <ItemAPIModel>(response);

            List <ItemModel> itemList = new List <ItemModel>();
            var itemPath = result.Response.Equipment.Data.Items;

            itemList = await GetItemInfoAsync(itemPath, member, itemList);

            return(itemList);
        }
Пример #26
0
        public List <MemberModel> GetMember()
        {
            try
            {
                DBResource newConnection = new DBResource();
                //newConnection.DBOpen();

                List <MemberModel> listModel = new List <MemberModel>();
                MemberModel        memberModel;

                using (SqlConnection myConnection = new SqlConnection(newConnection.connectionString.ToString()))
                {
                    string     query = "dbo.GetMembersPerAccount";
                    SqlCommand cmd   = new SqlCommand(query, myConnection);
                    myConnection.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            memberModel = new MemberModel();

                            memberModel.EmpID       = dr["EMP_NO"].ToString();
                            memberModel.CompanyName = dr["ACCOUNT_NAME"].ToString();
                            memberModel.MemberCode  = dr["MemberCode"].ToString();
                            memberModel.LName       = dr["lastname"].ToString();
                            memberModel.FName       = dr["firstname"].ToString();
                            memberModel.MName       = dr["middle_name"].ToString();
                            memberModel.BDate       = Convert.ToDateTime(dr["MEM_BDAY"]).ToString("dd/MM/yyyy");
                            //memberModel.Age = dr.GetInt32(dr.GetOrdinal("Age"));
                            memberModel.Gender = dr["gender"].ToString();

                            listModel.Add(memberModel);
                        }
                        myConnection.Close();
                    }
                }
                return(listModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #27
0
        static void ExtractType(string type, MemberModel member)
        {
            // Package or Class
            if (string.IsNullOrEmpty(type))
            {
                if (member.Flags != 0)
                {
                    return;
                }

                if (char.IsLower(member.Name[0]))
                {
                    member.Flags = FlagType.Package;
                }
                else
                {
                    member.Flags = FlagType.Class;
                }
            }
            // Function or Variable
            else
            {
                var types = type.Split(new[] { "->" }, StringSplitOptions.RemoveEmptyEntries);
                if (types.Length > 1)
                {
                    member.Flags      = FlagType.Function;
                    member.Parameters = new List <MemberModel>();
                    for (int i = 0; i < types.Length - 1; i++)
                    {
                        var param = new MemberModel(types[i].Trim(), "", FlagType.ParameterVar, Visibility.Public);
                        member.Parameters.Add(param);
                    }
                    member.Type = types[types.Length - 1].Trim();
                }
                else
                {
                    if (member.Flags == 0)
                    {
                        member.Flags = FlagType.Variable;
                    }
                    member.Type = type;
                }
            }
        }
Пример #28
0
        public ActionResult DoSubmit()
        {
            MemberModel member = new MemberModel();
            member = WebUtil.Eval<MemberModel>(member, "", "");

            ViewData[typeof(MemberModel).Name] = member;
            DataBiz dataBiz = DataBiz.GetInstant();
            JsResultObject re= dataBiz.checkMemberRegInfo(member);
            if (re.code == JsResultObject.CODE_SUCCESS) {

                re = dataBiz.submitMemberRegInfo(member);
                if (re.code == JsResultObject.CODE_SUCCESS)
                {
                    /*
                    MemberRewardModel reward = new MemberRewardModel();
                    reward.busType = MemberRewardModel.BUS_TYPE_NEW_MEMBER;
                    reward.amount = 10;
                    reward.remark = string.Format("{0}新会员注册成功",DateTime.Now.ToShortDateString());
                    reward.memberFk = member.id;
                    reward.createDate = DateTime.Now;
                    reward.setPk(reward.createPk());
                    reward.rebateStatus = MemberRewardModel.REBATE_STATUS_UNREBATED;
                    re= BaseZdBiz.Save(reward);
                     */
                    member.pwd = "";
                    WebUtil.SetSessionAttr(typeof(MemberModel).Name, member);
                    OrderModel order = WebUtil.GetSessionAttr<OrderModel>(typeof(OrderModel).Name);
                    if (order != null) {
                        order = BaseZdBiz.Load<OrderModel>(order.id);
                        order.memberFk = member.id;
                        BaseZdBiz.Update(order,"");
                        WebUtil.SetSessionAttr(typeof(OrderModel).Name, null);
                    }
                    return View("RequestVaildate");
                }
                else
                {
                    return View("Error");
                }

            }
            ViewData[typeof(JsResultObject).Name] = re;
            return View("Index");
        }
Пример #29
0
        /// <summary>
        /// Returns parameters string as member list
        /// </summary>
        /// <param name="parameters">Method parameters</param>
        /// <returns>Member list</returns>
        private static IEnumerable <MemberModel> ParseMethodParameters(string parameters)
        {
            var list = new List <MemberModel>();

            if (parameters == null)
            {
                return(list);
            }
            var p = parameters.IndexOf('(');

            if (p >= 0)
            {
                parameters = parameters.Substring(p + 1, parameters.IndexOf(')') - p - 1);
            }
            parameters = parameters.Trim();
            if (parameters.Length == 0)
            {
                return(list);
            }
            var toClean = new[] { ' ', '\t', '\n', '\r', '*', '?' };

            foreach (var parameter in parameters.Split(','))
            {
                var parType = parameter.Split(':');
                var param   = new MemberModel {
                    Name = parType[0].Trim(toClean)
                };
                if (param.Name.Length == 0)
                {
                    continue;
                }
                if (parType.Length == 2)
                {
                    param.Type = parType[1].Trim();
                }
                else
                {
                    param.Type = ASContext.Context.Features.objectKey;
                }
                param.Flags = FlagType.Variable | FlagType.Dynamic;
                list.Add(param);
            }
            return(list);
        }
Пример #30
0
        public ActionResult Login(MemberModel model)
        {
            var member = MemberHandler.GetMember(model.EmailAddress, model.Password);

            if (member != null)
            {
                Session[Constants.AppUserKeyName] = PublicUser.GetCurrentUser(member);

                var mongoCart   = CartHandler.GetCart(member.MemberId);
                var sessionCart = (Cart)Session[Constants.CartKeyName];

                if (sessionCart != null && sessionCart.Items != null && sessionCart.Items.Count > 0)
                {
                    if (mongoCart != null && mongoCart.Items != null && mongoCart.Items.Count > 0)
                    {
                        foreach (var sessionItem in sessionCart.Items)
                        {
                            var mongoItem = mongoCart.Items.Find(p => p.ProductId == sessionItem.ProductId);
                            if (mongoItem != null)
                            {
                                mongoItem.ProductCount = sessionItem.ProductCount;
                            }
                            else
                            {
                                mongoCart.Items.Add(sessionItem);
                            }
                        }
                    }
                    else
                    {
                        mongoCart = sessionCart;
                    }
                }

                Session[Constants.CartKeyName] = null;
                mongoCart.MemberId             = member.MemberId;
                CartHandler.SaveCart(mongoCart);

                return(RedirectToAction("Index", "Home", new { area = "" }));
            }

            ViewBag.LoginError = "Username and password does not match.";
            return(View());
        }
Пример #31
0
        public ResponseModel SaveMember(MemberModel modl)
        {
            ResponseModel resp = new ResponseModel();

            try
            {
                using (SqlConnection db = new SqlConnection(Connection.connString))
                {
                    string sqlQuery = "Insert Into [Member] ([FirstName],[MidName],[LastName],[EmailAdd],[City],[Province],[AreaCode]" +
                                      ",[contactNum],[bcbpGroup],[Position],[status],[YearOfMembership]" +
                                      ",[CLPNum], [Chapter],[AccessType]) " +
                                      "Values(@FirstName, @MidName, @LastName, @EmailAdd, @City, @Province, @AreaCode, " +
                                      "@contactNum, @bcbpGroup, @Position, @status, @YearOfMembership, @CLPNum, @Chapter, @AccessType)";

                    var x = db.Execute(sqlQuery, new
                    {
                        FirstName        = modl.FirstName,
                        MidName          = modl.MidName,
                        LastName         = modl.LastName,
                        EmailAdd         = modl.EmailAdd,
                        City             = modl.City,
                        Province         = modl.Province,
                        AreaCode         = modl.AreaCode,
                        contactNum       = modl.contactNum,
                        bcbpGroup        = modl.bcbpGroup,
                        Position         = modl.Position,
                        status           = modl.status,
                        YearOfMembership = modl.YearOfMembership,
                        CLPNum           = modl.CLPNum,
                        Chapter          = modl.Chapter,
                        AccessType       = modl.AccessType
                    });
                }
                resp.status = 1;
                resp.msg    = "Item inserted - Success";
            }
            catch (Exception ex)
            {
                resp.status = 0;
                resp.msg    = "Item inserted - Failed : " + ex.Message;
            }

            return(resp);
        }
Пример #32
0
        public ActionResult DoSubmitOrder(string arraivalLastTimeType)
        {
            JsResultObject re     = new JsResultObject();
            MemberModel    member = this.getAuthMember();


            OrderModel order = new OrderModel();

            DateTimeUtil.FixMSSQLNullDateTime(ref order);
            order.createDate = DateTime.Now;

            order = WebUtil.Eval(order, "", "");

            if (member != null)
            {
                order.memberFk = member.id;
                // re.code = JsResultObject.CODE_ALERT;
                // re.msg = "未登录用户不能进行酒店预定";

                // WebUtil.SetSessionAttr(typeof(JsResultObject).Name,re);
                // return RedirectToAction("Login","Home");
                //WebUtil.SetSessionAttr(typeof(OrderModel).Name, order);
            }
            if (arraivalLastTimeType == "a")
            {
                order.arraivalLateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 18, 0, 0);
            }
            else if (arraivalLastTimeType == "b")
            {
                DateTime dt = DateTime.Now.AddDays(1);
                order.arraivalLateTime = new DateTime(dt.Year, dt.Month, dt.Day, 6, 0, 0);
            }

            DataBiz dataBiz = DataBiz.GetInstant();

            re = dataBiz.createNewOrder(order);
            re.attrs.Add(typeof(OrderModel).Name, order);
            ViewData[typeof(JsResultObject).Name] = re;

            HotelRoomModel room = BaseZdBiz.Load <HotelRoomModel>(Restrictions.Eq("hotelFk", order.hotelId), Restrictions.Eq("roomTypeId", order.roomTypeId));

            ViewData[typeof(HotelRoomModel).Name] = room;
            return(View("OrderFeedback"));
        }
Пример #33
0
        public JsonResult GetMemberListForSetCommittee(MemberModel model)
        {
            var MemberDB = db.Members.ToList();

            if (model.Status == true)
            {
                var CommitteeMemberDB = db.CommitteeMemberViews.ToList();
                CommitteeMemberDB = db.CommitteeMemberViews.Where(x => x.Committee_Id == model.SelectedCommittee && x.MemberCommiitteStatus == true && x.Status == true).ToList();
                List <MemberModel> vm = CommitteeMemberDB.Select(x => new MemberModel
                {
                    Name               = x.Name,
                    RId                = x.RId,
                    Id                 = x.Id,
                    Address            = x.Address,
                    Email              = x.Email,
                    Gender             = x.Gender,
                    Phone              = x.Phone,
                    RoleId             = x.Role_Id.GetValueOrDefault(),
                    RoleName           = x.RoleName,
                    CommitteeId        = x.Committee_Id.GetValueOrDefault(),
                    CommitteName       = x.CommitteeName,
                    MemberInCommittee  = x.MemberCommiitteStatus.GetValueOrDefault(),
                    CommitteMemberId   = x.CommitteMemberId.GetValueOrDefault(),
                    UserName           = x.UserName,
                    UserStatus         = x.UserStatus,
                    UserCommitteeId    = x.UserCommitteId,
                    UserOrganizationId = x.UserOrganizationId
                }).ToList();
                return(Json(vm, JsonRequestBehavior.AllowGet));
            }
            else
            {
                List <MemberModel> vm = MemberDB.Where(s => s.Organization_Id == model.OrganizationId && model.SelectedCommittee != 0 && s.Status == true).Select(x => new MemberModel
                {
                    Name       = x.Name,
                    Id         = x.Id,
                    Email      = x.Email,
                    Gender     = x.Gender,
                    Phone      = x.Phone,
                    Validation = ExistMember(model.SelectedCommittee, x.Id)
                }).ToList();
                return(Json(vm, JsonRequestBehavior.AllowGet));
            }
        }
Пример #34
0
        private MemberModel ReadField(JsonReader reader, ClassModel cClass)
        {
            MemberModel member = new MemberModel();
            member.Flags = FlagType.Variable;

            string prop = null;
            while (reader.Read())
            {
                if (reader.Token == JsonToken.ObjectEnd) break;
                if (reader.Token == JsonToken.PropertyName) prop = reader.Value.ToString();
                else if (reader.Token == JsonToken.String)
                {
                    string val = reader.Value.ToString();
                    switch (prop)
                    {
                        case "name": member.Name = val; cClass.Members.Add(member); break;
                        case "type": if (member.Type == null) member.Type = CleanType(val); break;
                        case "docstring": member.Comments = ExtractDoc(val); break;
                    }
                }
                else if (reader.Token == JsonToken.ArrayStart)
                {
                    switch (prop)
                    {
                        case "fieldattributes":
                            ReadAttributes(reader, member);
                            if ((member.Flags & FlagType.Static) == 0) member.Flags |= FlagType.Dynamic;
                            break;
                        case "metainfo": ReadMetas(reader, member); break;
                        default: reader.SkipArray(); break;
                    }
                }
                else if (reader.Token == JsonToken.ObjectStart)
                {
                    switch (prop)
                    {
                        case "templatetypes": ReadTemplateTypes(reader, member); break;
                        default: reader.SkipObject(); break;
                    }
                }
            }
            return member;
        }
Пример #35
0
        public void removeMember()
        {
            int         id;
            MemberModel uniqueMember = new MemberModel();

            do
            {
                Console.WriteLine("=========================");
                Console.WriteLine("Enter member ID.");
                id = Convert.ToInt32(Console.ReadLine());
            } while (id.ToString().Length < 0);

            try
            {
                uniqueMember = database.findMemberInDb(id);
            }
            catch
            {
                throw new Exception("Error while deleting member");
            }

            Console.WriteLine("=========================");
            Console.WriteLine($"Do you want to delete {uniqueMember.Name}?");
            Console.WriteLine("1. Yes");
            Console.WriteLine("2. No");

            switch (Console.ReadLine())
            {
            case "1":
                database.removeMember(id);
                System.Console.WriteLine("Member was removed");
                System.Console.WriteLine("Press any button to exit");
                Console.ReadKey(true);
                break;

            case "2":
                memberMenu();
                break;

            default:
                break;
            }
        }
Пример #36
0
        public ActionResult DoConfirm()
        {
            MemberModel member = new MemberModel();

            member = WebUtil.Eval <MemberModel>(member, "", "");
            member.setPk(member.createPk());
            JsResultObject re = BaseZdBiz.Save(member);

            if (re.code == JsResultObject.CODE_SUCCESS)
            {
                bool isSended = EMailUtil.SendMail("捷达商旅会员信息确认", "会员号", new string[] { member.email });
                ViewData[typeof(MemberModel).Name] = member;
                return(View("RequestVaildate"));
            }
            else
            {
                return(View("Error"));
            }
        }
Пример #37
0
        public JsResultObject rebateReward(MemberModel member, int rebateAmount, string remark)
        {
            JsResultObject     re      = new JsResultObject();
            MemberAccountModel account = getCurrMemberAccount(member);

            if (member.rebateInd != BaseModel.IND_Y)
            {
                re.code = JsResultObject.CODE_ERROR;
                re.msg  = string.Format("当前用户尚未申请返还", account.newAmount, rebateAmount);
                return(re);
            }
            else if (account.newAmount < rebateAmount)
            {
                re.code = JsResultObject.CODE_ERROR;
                re.msg  = string.Format("当前用户帐户奖励{0},小于{1},返还无效", account.newAmount, rebateAmount);
                return(re);
            }
            MemberAccountModel newAccount = new MemberAccountModel();

            newAccount.createDate = DateTime.Now;
            newAccount.oldAmount  = account.newAmount;
            newAccount.newAmount  = account.newAmount - rebateAmount;
            newAccount.remark     = remark;
            newAccount.memberFk   = member.id;
            newAccount.method     = MemberAccountModel.METHOD_REWARD_REBATE;
            newAccount.setPk(newAccount.createPk());
            newAccount.remark = string.Format("成功为手机号码{0}充值{1}元", member.rebateMoblie, rebateAmount);
            re = BaseZdBiz.Save(newAccount);
            if (re.code == JsResultObject.CODE_SUCCESS)
            {
                MemberRewardLogModel rewardLog = new MemberRewardLogModel();
                rewardLog.createDate = DateTime.Now;
                rewardLog.amount     = rebateAmount;
                rewardLog.moblie     = member.rebateMoblie;
                rewardLog.method     = MemberAccountModel.METHOD_REWARD_REBATE;
                rewardLog.remark     = string.Format("成功为手机号码{0}充值{1}元", member.rebateMoblie, rebateAmount);
                rewardLog.status     = BaseModel.STATUS_ACTIVATE;
                rewardLog.memberFk   = member.id;
                rewardLog.setPk(rewardLog.createPk());
                re = BaseZdBiz.Save(rewardLog);
            }
            return(re);
        }
Пример #38
0
        public bool Post(MemberModel model)
        {
            var entity = new MemberEntity
            {
                User = model.User,

                OpenId = model.OpenId,

//				Orders = model.Orders,

                ContactName = model.ContactName,
            };

            if (_MemberService.Create(entity).Id > 0)
            {
                return(true);
            }
            return(false);
        }
Пример #39
0
        public JsResultObject submitMemberRegInfo(MemberModel member)
        {
            JsResultObject re = BaseZdBiz.Save(member);

            if (re.code == JsResultObject.CODE_SUCCESS)
            {
                MemberRewardRuleModel rule    = GetCurRewardRule();
                MemberAccountModel    account = new MemberAccountModel(member.id);
                account.oldAmount    = 0;
                account.newAmount    = 10;
                account.changeAmount = 10;
                account.createDate   = DateTime.Now;
                account.method       = MemberAccountModel.METHOD_ACCOUNT_CREATE;
                account.remark       = string.Format("帐号创建成功,获得奖励{0}元", 10);
                account.setPk(account.createPk());
                re = BaseZdBiz.Save(account);
            }
            return(re);
        }
Пример #40
0
 public JsResultObject login(MemberModel member,string key)
 {
     JsResultObject re = new JsResultObject();
     this.OpenSession();
     ICriteria icr = this.session.CreateCriteria<MemberModel>();
     icr.Add(Restrictions.Or(Restrictions.Eq("id",key),Restrictions.Or(Restrictions.Eq("email",key) ,Restrictions.Eq("moblie", key))));
     icr.Add(Restrictions.Eq("pwd", member.pwd));
     IList<MemberModel> members = icr.List<MemberModel>();
     if (members.Count == 1) {
         re.code = JsResultObject.CODE_SUCCESS;
         re.msg = string.Format("会员 {0} 登陆成功",member.nickName);
         members[0].pwd = null;
         re.attrs.Add(typeof(MemberModel).Name, members[0]);
     }else{
         re.code = JsResultObject.CODE_ERROR;
         re.msg = string.Format("帐号 {0} 登陆失败",member.nickName);
     }
     return re;
 }
Пример #41
0
        public dynamic Member_ConvertToAPIEntity(MemberModel local)
        {
            dynamic apiObj = new
            {
                id     = local.Id,
                siteId = local.SiteId,
                //Type = data["Type"],
                firstName   = local.FirstName,
                surname     = local.Surname,
                email       = local.Email,
                dateCreated = local.DateCreated,
                status      = local.Status,
                userId      = local.UserId,
                data        = local.Data,
                resumeFiles = local.ResumeFiles
            };

            return(apiObj);
        }
Пример #42
0
        public void parseJoinRe(PartyServerModel _serverParty)
        {
            foreach (MemberModelInt membInt in _serverParty.members)
            {
                MemberModel newMemb = getMember(membInt);
                ClientStaticData.currentParty.partyMembers.Add(newMemb);
            }

            if (!string.IsNullOrEmpty(_serverParty.mapIDSelected))
            {
                ClientStaticData.currentParty.mapSelected = HomeUtil.mapIdsToMaps(_serverParty.mapIDSelected);
            }

            ClientStaticData.currentParty.partyState = getPartyState(_serverParty.state);

            ClientStaticData.currentParty.mapHistory     = HomeUtil.mapIdsToMaps(_serverParty.mapHistory);
            ClientStaticData.currentParty.suggestedMaps  = HomeUtil.mapIdsToMaps(_serverParty.suggestedMaps);
            ClientStaticData.currentParty.inviteRequests = _serverParty.inviteRequests;
        }
Пример #43
0
        public ActionResult Edit(int id)
        {
            var member = jlService.GetMember(id);

            var model = new MemberModel();

            model.Address     = member.Address;
            model.Description = member.Description;
            model.Email       = member.Email;
            model.JoinTime    = member.JoinTime;
            model.Name        = member.RealName;
            model.NickName    = member.NickName;
            model.Phone       = member.Phone;
            model.Picture     = member.Picture;
            model.QQ          = member.QQ;
            model.Status      = member.Status;

            return(View(model));
        }
Пример #44
0
        public IActionResult Register(MemberModel memberModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(memberModel));
            }

            memberModel.EmployeeStatus = EmployeeStatus.Working;
            memberModel.StartedWork    = DateTime.Now;
            var result = _memberRest.Register(memberModel);

            if (!result.Success)
            {
                ViewBag.Error = result.Messages;
                return(View(memberModel));
            }

            return(RedirectToAction(nameof(Index), new { vehicleId = memberModel.VehicleId, occupation = memberModel.occupation }));
        }
Пример #45
0
        public static string GetStaticExternOverride(MemberModel member)
        {
            FlagType ft        = member.Flags;
            string   modifiers = "";

            if ((ft & FlagType.Extern) > 0)
            {
                modifiers += "extern ";
            }
            if ((ft & FlagType.Static) > 0)
            {
                modifiers += "static ";
            }
            if ((ft & FlagType.Override) > 0)
            {
                modifiers += "override ";
            }
            return(modifiers);
        }
Пример #46
0
        public static string ToDeclarationWithModifiersString(MemberModel m, string template)
        {
            bool isConstructor = (m.Flags & FlagType.Constructor) > 0;

            string methodModifiers;
            if (isConstructor)
                methodModifiers = GetModifiers(m).Trim();
            else
                methodModifiers = (GetStaticExternOverride(m) + GetModifiers(m)).Trim();

            // Insert Modifiers (private, static, etc)
            if (methodModifiers == "private" && ASContext.Context.Features.methodModifierDefault == Visibility.Private)
                methodModifiers = null;
            string res = ReplaceTemplateVariable(template, "Modifiers", methodModifiers);

            // Insert Declaration
            res = ToDeclarationString(m, res);

            return res;
        }
Пример #47
0
        public MemberTreeNode(MemberModel memberModel, int imageIndex, bool labelPropertiesLikeFunctions)
            : base(memberModel.ToString(), imageIndex, imageIndex)
        {
            if (labelPropertiesLikeFunctions &&
                (memberModel.Flags & (FlagType.Setter | FlagType.Getter)) != 0)
            {
                var paramList = string.Empty;
                if (memberModel.Parameters != null)
                    paramList = string.Join(", ", memberModel.Parameters.Select(p => string.Format("{0}:{1}", p.Name, p.Type)).ToArray());

                Label = string.Format("{0} ({1}) : {2}", memberModel.Name, paramList, memberModel.Type);
            }
            else
            {
                Label = Text;
            }

            Model = memberModel;
            Tag = memberModel.Name + "@" + memberModel.LineFrom;
        }
        public void NewServeEvent(NewServeEventModel model)
        {
            try
            {
                //Prepare Event Information
                var eventName = model.Title;
                var sEvent = _eventService.GetServeEvent(eventName, DateTime.Today);
                if (sEvent == null)
                {
                    sEvent = _eventService.NewServeEvent(new serveevent() { Title = model.Title, StartDateTime = DateTime.Now });
                }

                //Get Member Information
                var client = new FSLLProxies.Core.Clients.AccountClient();
                var targetMember = client.GetMember(model.Target.ID).ToResult<FSLLProxies.Core.Models.MemberModel>();
                if (targetMember == null)
                {
                    targetMember = new MemberModel()
                    {
                        MemberName = model.Target.Name
                    };
                }

                //Update Member Requirements
                UpdateMemberRequirements(model.Requirements, targetMember);

                //Update Feedback
                UpdateServeEventFeedback(model.Feedbacks, sEvent.ID, targetMember);

                //Update Event From list
                UpdateServeEventFrom(model.Froms, sEvent.ID);

                //Update Event Target list
                UpdateServeEventTarget(model.Requirements, sEvent.ID, targetMember);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
        public static serveeventrequirement ToServeEventRequirement(this NewServeEventModel._RequirementModel model, int eventID, MemberModel target)
        {
            if (model == null)
                return null;

            var serveEventRequirement = new serveeventrequirement
            {
                Requirement = model.Title,
                RequirementDescription = model.Description,
                RequirementID = model.ID,
                ServeEventID = eventID,
                TargetMemberID = target.MemberID,
                TargetMemberName = target.MemberName
            };

            if (target.DefaultGroup != null)
            {
                serveEventRequirement.TargetMemberGroupID = target.DefaultGroup.GroupID;
                serveEventRequirement.TargetMemberGroupName = target.DefaultGroup.GroupName;
            }

            return serveEventRequirement;
        }
Пример #50
0
        static public void ContextualGenerator(ScintillaNet.ScintillaControl Sci)
        {
            if (ASContext.Context is ASContext) (ASContext.Context as ASContext).UpdateCurrentFile(false); // update model
            if ((ASContext.Context.CurrentClass.Flags & (FlagType.Enum | FlagType.TypeDef)) > 0) return;

            lookupPosition = -1;
            int position = Sci.CurrentPos;
            if (Sci.BaseStyleAt(position) == 19) // on keyword
                return;
            bool isNotInterface = (ASContext.Context.CurrentClass.Flags & FlagType.Interface) == 0;
            int line = Sci.LineFromPosition(position);
            contextToken = Sci.GetWordFromPosition(position);
            contextMatch = null;

            FoundDeclaration found = GetDeclarationAtLine(Sci, line);
            string text = Sci.GetLine(line);
            bool suggestItemDeclaration = false;

            if (isNotInterface && !String.IsNullOrEmpty(contextToken) && Char.IsDigit(contextToken[0]))
            {
                ShowConvertToConst(found);
                return;
            }

            ASResult resolve = ASComplete.GetExpressionType(Sci, Sci.WordEndPosition(position, true));
            contextResolved = resolve;
            
            // ignore automatic vars (MovieClip members)
            if (isNotInterface
                && resolve.Member != null
                && (((resolve.Member.Flags & FlagType.AutomaticVar) > 0) || (resolve.InClass != null && resolve.InClass.QualifiedName == "Object")))
            {
                resolve.Member = null;
                resolve.Type = null;
            }

            if (isNotInterface && found.inClass != ClassModel.VoidClass && contextToken != null)
            {
                if (resolve.Member == null && resolve.Type != null
                    && (resolve.Type.Flags & FlagType.Interface) > 0) // implement interface
                {
                    contextParam = resolve.Type.Type;
                    ShowImplementInterface(found);
                    return;
                }

                if (resolve.Member != null && !ASContext.Context.CurrentClass.IsVoid()
                    && (resolve.Member.Flags & FlagType.LocalVar) > 0) // promote to class var
                {
                    contextMember = resolve.Member;
                    ShowPromoteLocalAndAddParameter(found);
                    return;
                }
            }
            
            if (contextToken != null && resolve.Member == null) // import declaration
            {
                if ((resolve.Type == null || resolve.Type.IsVoid() || !ASContext.Context.IsImported(resolve.Type, line)) && CheckAutoImport(found)) return;
                if (resolve.Type == null)
                {
                    int stylemask = (1 << Sci.StyleBits) - 1;
                    suggestItemDeclaration = ASComplete.IsTextStyle(Sci.StyleAt(position - 1) & stylemask);
                }
            }

            if (isNotInterface && found.member != null)
            {
                // private var -> property
                if ((found.member.Flags & FlagType.Variable) > 0 && (found.member.Flags & FlagType.LocalVar) == 0)
                {
                    // maybe we just want to import the member's non-imported type
                    Match m = Regex.Match(text, String.Format(patternVarDecl, found.member.Name, contextToken));
                    if (m.Success)
                    {
                        contextMatch = m;
                        ClassModel type = ASContext.Context.ResolveType(contextToken, ASContext.Context.CurrentModel);
                        if (type.IsVoid() && CheckAutoImport(found))
                            return;
                    }
                    ShowGetSetList(found);
                    return;
                }
                // inside a function
                else if ((found.member.Flags & (FlagType.Function | FlagType.Getter | FlagType.Setter)) > 0
                    && resolve.Member == null && resolve.Type == null)
                {
                    if (contextToken != null)
                    {
                        // "generate event handlers" suggestion
                        string re = String.Format(patternEvent, contextToken);
                        Match m = Regex.Match(text, re, RegexOptions.IgnoreCase);
                        if (m.Success)
                        {
                            contextMatch = m;
                            contextParam = CheckEventType(m.Groups["event"].Value);
                            ShowEventList(found);
                            return;
                        }
                        m = Regex.Match(text, String.Format(patternAS2Delegate, contextToken), RegexOptions.IgnoreCase);
                        if (m.Success)
                        {
                            contextMatch = m;
                            ShowDelegateList(found);
                            return;
                        }
                        // suggest delegate
                        if (ASContext.Context.Features.hasDelegates)
                        {
                            m = Regex.Match(text, @"([a-z0-9_.]+)\s*\+=\s*" + contextToken, RegexOptions.IgnoreCase);
                            if (m.Success)
                            {
                                int offset = Sci.PositionFromLine(Sci.LineFromPosition(position))
                                    + m.Groups[1].Index + m.Groups[1].Length;
                                resolve = ASComplete.GetExpressionType(Sci, offset);
                                if (resolve.Member != null)
                                    contextMember = ResolveDelegate(resolve.Member.Type, resolve.InFile);
                                contextMatch = m;
                                ShowDelegateList(found);
                                return;
                            }
                        }
                    }
                    else
                    {
                        // insert a default handler name, then "generate event handlers" suggestion
                        Match m = Regex.Match(text, String.Format(patternEvent, ""), RegexOptions.IgnoreCase);
                        if (m.Success)
                        {
                            int regexIndex = m.Index + Sci.PositionFromLine(Sci.CurrentLine);
                            GenerateDefaultHandlerName(Sci, position, regexIndex, m.Groups["event"].Value, true);
                            resolve = ASComplete.GetExpressionType(Sci, Sci.CurrentPos);
                            if (resolve.Member == null || (resolve.Member.Flags & FlagType.AutomaticVar) > 0)
                            {
                                contextMatch = m;
                                contextParam = CheckEventType(m.Groups["event"].Value);
                                ShowEventList(found);
                            }
                            return;
                        }

                        // insert default delegate name, then "generate delegate" suggestion
                        if (ASContext.Context.Features.hasDelegates)
                        {
                            m = Regex.Match(text, @"([a-z0-9_.]+)\s*\+=\s*", RegexOptions.IgnoreCase);
                            if (m.Success)
                            {
                                int offset = Sci.PositionFromLine(Sci.LineFromPosition(position))
                                        + m.Groups[1].Index + m.Groups[1].Length;
                                resolve = ASComplete.GetExpressionType(Sci, offset);
                                if (resolve.Member != null)
                                {
                                    contextMember = ResolveDelegate(resolve.Member.Type, resolve.InFile);
                                    string delegateName = resolve.Member.Name;
                                    if (delegateName.StartsWith("on")) delegateName = delegateName.Substring(2);
                                    GenerateDefaultHandlerName(Sci, position, offset, delegateName, false);
                                    resolve = ASComplete.GetExpressionType(Sci, Sci.CurrentPos);
                                    if (resolve.Member == null || (resolve.Member.Flags & FlagType.AutomaticVar) > 0)
                                    {
                                        contextMatch = m;
                                        ShowDelegateList(found);
                                    }
                                    return;
                                }
                            }
                        }
                    }
                }

                // "Generate fields from parameters" suggestion
                if (found.member != null
                    && (found.member.Flags & FlagType.Function) > 0
                    && found.member.Parameters != null && (found.member.Parameters.Count > 0)
                    && resolve.Member != null && (resolve.Member.Flags & FlagType.ParameterVar) > 0)
                {
                    contextMember = resolve.Member;
                    ShowFieldFromParameter(found);
                    return;
                }

                // "add to interface" suggestion
                if (resolve.Member != null
                    && resolve.Member.Name == found.member.Name
                    && line == found.member.LineFrom
                    && ((found.member.Flags & FlagType.Function) > 0 
                            || (found.member.Flags & FlagType.Getter) > 0
                            || (found.member.Flags & FlagType.Setter) > 0)
                    && found.inClass != ClassModel.VoidClass
                    && found.inClass.Implements != null
                    && found.inClass.Implements.Count > 0)
                {
                    string funcName = found.member.Name;
                    FlagType flags = found.member.Flags & ~FlagType.Access;
                    
                    List<string> interfaces = new List<string>();
                    foreach (string interf in found.inClass.Implements)
                    {
                        bool skip = false;
                        ClassModel cm = ASContext.Context.ResolveType(interf, ASContext.Context.CurrentModel);
                        foreach (MemberModel m in cm.Members)
                        {
                            if (m.Name.Equals(funcName) && m.Flags.Equals(flags))
                            {
                                skip = true;
                                break;
                            }
                        }
                        if (!skip)
                        {
                            interfaces.Add(interf);
                        }
                    }
                    if (interfaces.Count > 0)
                    {
                        ShowAddInterfaceDefList(found, interfaces);
                        return;
                    }
                }

                // "assign var to statement" suggestion
                int curLine = Sci.CurrentLine;
                string ln = Sci.GetLine(curLine).TrimEnd();
                if (ln.Length > 0 && ln.IndexOf("=") == -1 
                    && ln.Length <= Sci.CurrentPos - Sci.PositionFromLine(curLine)) // cursor at end of line
                {
                    ShowAssignStatementToVarList(found);
                    return;
                }
            }
            
            // suggest generate constructor / toString
            if (isNotInterface && found.member == null && found.inClass != ClassModel.VoidClass && contextToken == null)
            {
                bool hasConstructor = false;
                bool hasToString = false;
                foreach (MemberModel m in ASContext.Context.CurrentClass.Members)
                {
                    if (!hasConstructor && (m.Flags & FlagType.Constructor) > 0)
                        hasConstructor = true;

                    if (!hasToString && (m.Flags & FlagType.Function) > 0 && m.Name.Equals("toString"))
                        hasToString = true;
                }

                if (!hasConstructor || !hasToString)
                {
                    ShowConstructorAndToStringList(found, hasConstructor, hasToString);
                    return;
                }
            }

            if (isNotInterface 
                && resolve.Member != null
                && resolve.Type != null
                && resolve.Type.QualifiedName == "String"
                && found.inClass != ClassModel.VoidClass)
            {
                int lineStartPos = Sci.PositionFromLine(Sci.CurrentLine);
                string lineStart = text.Substring(0, Sci.CurrentPos - lineStartPos);
                Match m = Regex.Match(lineStart, String.Format(@"new\s+(?<event>\w+)\s*\(\s*\w+", lineStart));
                if (m.Success)
                {
                    Group g = m.Groups["event"];
                    ASResult eventResolve = ASComplete.GetExpressionType(Sci, lineStartPos + g.Index + g.Length);
                    if (eventResolve != null && eventResolve.Type != null)
                    {
                        ClassModel aType = eventResolve.Type;
                        aType.ResolveExtends();
                        while (!aType.IsVoid() && aType.QualifiedName != "Object")
                        {
                            if (aType.QualifiedName == "flash.events.Event")
                            {
                                contextParam = eventResolve.Type.QualifiedName;
                                ShowEventMetatagList(found);
                                return;
                            }
                            aType = aType.Extends;
                        }
                    }
                }
            }
            
            // suggest declaration
            if (contextToken != null)
            {
                if (suggestItemDeclaration)
                {
                    Match m = Regex.Match(text, String.Format(patternClass, contextToken));
                    if (m.Success)
                    {
                        contextMatch = m;
                        ShowNewClassList(found);
                    }
                    else if (!found.inClass.IsVoid())
                    {
                        m = Regex.Match(text, String.Format(patternMethod, contextToken));
                        if (m.Success)
                        {
                            contextMatch = m;
                            ShowNewMethodList(found);
                        }
                        else ShowNewVarList(found);
                    }
                }
                else
                {
                    if (resolve != null
                        && resolve.InClass != null
                        && resolve.InClass.InFile != null
                        && resolve.Member != null
                        && (resolve.Member.Flags & FlagType.Function) > 0
                        && File.Exists(resolve.InClass.InFile.FileName)
                        && !resolve.InClass.InFile.FileName.StartsWith(PathHelper.AppDir))
                    {
                        Match m = Regex.Match(text, String.Format(patternMethodDecl, contextToken));
                        Match m2 = Regex.Match(text, String.Format(patternMethod, contextToken));
                        if (!m.Success && m2.Success)
                        {
                            contextMatch = m;
                            ShowChangeMethodDeclList(found);
                        }
                    }
                    else if (resolve != null
                        && resolve.Type != null
                        && resolve.Type.InFile != null
                        && resolve.RelClass != null
                        && File.Exists(resolve.Type.InFile.FileName)
                        && !resolve.Type.InFile.FileName.StartsWith(PathHelper.AppDir))
                    {
                        Match m = Regex.Match(text, String.Format(patternClass, contextToken));
                        if (m.Success)
                        {
                            contextMatch = m;
                            ShowChangeConstructorDeclList(found);
                        }
                    }
                }
            }
            // TODO: Empty line, show generators list?
        }
Пример #51
0
 private void ReadAttributes(JsonReader reader, MemberModel decl)
 {
     while (reader.Read())
     {
         if (reader.Token == JsonToken.ArrayEnd) break;
         if (reader.Token == JsonToken.String)
         {
             string val = reader.Value.ToString();
             switch (val)
             {
                 case "native": decl.Flags |= FlagType.Native; break;
                 case "static": decl.Flags |= FlagType.Static; break;
                 case "public": decl.Access |= Visibility.Public; break;
                 case "internal": decl.Access |= Visibility.Internal; break;
                 case "protected": decl.Access |= Visibility.Protected; break;
                 case "private": decl.Access |= Visibility.Private; break;
                 case "final": decl.Flags |= FlagType.Final; break;
                 case "operator": break;
                 case "supercall": break;
                 default: break;
             }
         }
     }
 }
Пример #52
0
 private void ReadMetas(JsonReader reader, MemberModel member)
 {
     reader.SkipArray();
 }
Пример #53
0
        private MemberModel ReadParameter(JsonReader reader, MemberModel member)
        {
            MemberModel para = new MemberModel("???", null, FlagType.Variable | FlagType.ParameterVar, Visibility.Public);
            member.Parameters.Add(para);

            string prop = null;
            bool isRest = false;
            while (reader.Read())
            {
                if (reader.Token == JsonToken.ObjectEnd) break;
                if (reader.Token == JsonToken.PropertyName) prop = reader.Value.ToString();
                else if (reader.Token == JsonToken.String)
                {
                    string val = reader.Value.ToString();
                    switch (prop)
                    {
                        case "hasdefault": para.Value = "?"; break; // TODO "hasdefault" is that used?
                        case "isvarargs": isRest = true; break;  // TODO "isvarargs" is that used?
                        case "name": para.Name = val; break;
                        case "type": if (para.Type == null) para.Type = CleanType(val); break;
                    }
                }
                else if (reader.Token == JsonToken.ObjectStart)
                {
                    switch (prop)
                    {
                        case "templatetypes": ReadTemplateTypes(reader, para); break;
                        default: reader.SkipObject(); break;
                    }
                }
            }
            if (isRest) para.Type = "..." + para.Type;
            return para;
        }
Пример #54
0
        private void ReadParameters(JsonReader reader, MemberModel member)
        {
            member.Parameters = new List<MemberModel>();

            while (reader.Read())
            {
                if (reader.Token == JsonToken.ArrayEnd) break;
                if (reader.Token == JsonToken.ObjectStart) ReadParameter(reader, member);
            }
        }
Пример #55
0
 private void ReadTemplateTypes(JsonReader reader, MemberModel member)
 {
     string prop = null;
     List<string> names = null;
     while (reader.Read())
     {
         if (reader.Token == JsonToken.ObjectEnd) break;
         if (reader.Token == JsonToken.PropertyName) prop = reader.Value.ToString();
         else if (reader.Token == JsonToken.String)
         {
             string val = reader.Value.ToString();
             switch (prop)
             {
                 case "type": member.Type = CleanType(val); break;
             }
         }
         else if (reader.Token == JsonToken.ArrayStart)
         {
             switch (prop)
             {
                 case "types": names = ReadNames(reader); break;
                 default: reader.SkipArray(); break;
             }
         }
     }
     if (names != null) 
         member.Type += ".<" + String.Join(",", names.ToArray()) + ">";
 }
Пример #56
0
        private void ReadProperty(JsonReader reader, ClassModel cClass)
        {
            MemberModel member = new MemberModel();
            member.Flags = FlagType.Variable;

            MemberModel getter = null;
            MemberModel setter = null;
            string prop = null;
            string name = null;
            string doc = null;
            while (reader.Read())
            {
                if (reader.Token == JsonToken.ObjectEnd) break;
                if (reader.Token == JsonToken.PropertyName) prop = reader.Value.ToString();
                else if (reader.Token == JsonToken.String)
                {
                    string val = reader.Value.ToString();
                    switch (prop)
                    {
                        case "name": name = val; break;
                        case "docstring": doc = ExtractDoc(val); break;
                    }
                }
                else if (reader.Token == JsonToken.ArrayStart)
                {
                    switch (prop)
                    {
                        //case "propertyattributes": ReadAttributes(reader, member); break;
                        //case "metainfo": reader.SkipArray(); break;
                        default: reader.SkipArray(); break;
                    }
                }
                else if (reader.Token == JsonToken.ObjectStart)
                {
                    switch (prop)
                    {
                        case "getter": 
                            getter = ReadMethod(reader, cClass);
                            getter.Flags |= FlagType.Getter;
                            break;
                        case "setter":
                            setter = ReadMethod(reader, cClass);
                            setter.Flags |= FlagType.Setter;
                            break;
                        default: reader.SkipObject(); break;
                    }
                }
            }
            if (getter != null)
            {
                getter.Name = name;
                getter.Comments = doc;
                getter.Flags &= ~FlagType.Function;
            }
            if (setter != null)
            {
                setter.Name = name;
                if (getter == null) setter.Comments = doc;
                setter.Flags &= ~FlagType.Function;
            }
        }
Пример #57
0
        private MemberModel ReadMethod(JsonReader reader, ClassModel cClass)
        {
            MemberModel member = new MemberModel();
            member.Flags = FlagType.Function;

            string prop = null;
            while (reader.Read())
            {
                if (reader.Token == JsonToken.ObjectEnd) break;
                if (reader.Token == JsonToken.PropertyName) prop = reader.Value.ToString();
                else if (reader.Token == JsonToken.String)
                {
                    string val = reader.Value.ToString();
                    switch (prop)
                    {
                        case "name": 
                            if (!val.StartsWith("__op_")) {
                                member.Name = val; 
                                cClass.Members.Add(member); 
                            }
                            break;
                        case "returntype": if (member.Type == null) member.Type = CleanType(val); break;
                        case "docstring": member.Comments = ExtractDoc(val); break;
                    }
                }
                else if (reader.Token == JsonToken.ArrayStart)
                {
                    switch (prop)
                    {
                        case "methodattributes": 
                            ReadAttributes(reader, member); 
                            if ((member.Flags & FlagType.Static) == 0) member.Flags |= FlagType.Dynamic;
                            break;
                        case "parameters": ReadParameters(reader, member); break;
                        case "metainfo": ReadMetas(reader, member); break;
                        default: reader.SkipArray(); break;
                    }
                }
                else if (reader.Token == JsonToken.ObjectStart)
                {
                    switch (prop)
                    {
                        case "templatetypes": ReadTemplateTypes(reader, member); break;
                        default: reader.SkipObject(); break;
                    }
                }
            }
            return member;
        }
Пример #58
0
        private void ReadType(JsonReader reader)
        {
            // root/modules/types
            FileModel cFile;
            ClassModel cClass;
            cFile = new FileModel();
            cFile.HasPackage = true;
            cFile.Version = 3;
            cFile.Context = context;
            cClass = new ClassModel();
            cClass.Flags = FlagType.Class;
            MemberModel cDelegate = new MemberModel();
            List<string> names;

            string prop = null;
            while (reader.Read())
            {
                if (reader.Token == JsonToken.ObjectEnd) break;
                if (reader.Token == JsonToken.PropertyName) prop = reader.Value.ToString();
                else if (reader.Token == JsonToken.String)
                {
                    string val = reader.Value.ToString();
                    switch (prop)
                    {
                        case "name": cClass.Name = val; break;
                        case "source":
                            if (val.IndexOf('/') > 0) val = val.Substring(val.IndexOf('/') + 1);
                            cFile.FileName = path.Path + "::" + val;
                            break;
                        case "package":
                            if (val.ToLower() == "cocos2d") val = "cocos2d"; // random casing through source
                            cFile.Package = val; 
                            break;
                        case "baseType": cClass.ExtendsType = val; break;
                        case "delegateReturnType": cDelegate.Type = CleanType(val); break;
                        case "type":
                            switch (val)
                            {
                                case "CLASS": break;
                                case "INTERFACE": cClass.Flags |= FlagType.Interface; break;
                                case "STRUCT": cClass.Flags |= FlagType.Struct; break;
                                case "DELEGATE": cDelegate.Name = cClass.Name; break;
                            }
                            break;
                        case "docstring": cClass.Comments = ExtractDoc(val); break;
                    }
                }
                else if (reader.Token == JsonToken.ArrayStart)
                {
                    switch (prop)
                    {
                        case "classattributes": ReadAttributes(reader, cClass); break;
                        case "fields": ReadFields(reader, cClass); break;
                        case "methods": ReadMethods(reader, cClass); break;
                        case "properties": ReadProperties(reader, cClass); break;
                        case "metainfo": ReadMetas(reader, cClass); break;
                        case "imports": 
                            names = ReadNames(reader);
                            foreach (string name in names)
                                cFile.Imports.Add(new MemberModel(name, name, FlagType.Import, Visibility.Public)); 
                            break;
                        case "interfaces": ReadInterfaces(reader, cClass); break;
                        case "delegateTypes":
                            names = ReadNames(reader);
                            if (names.Count > 0)
                            {
                                cDelegate.Parameters = new List<MemberModel>();
                                foreach (string argType in names)
                                {
                                    cDelegate.Parameters.Add(
                                        new MemberModel("p" + cDelegate.Parameters.Count, argType, FlagType.ParameterVar, Visibility.Public));
                                }
                            }
                            break;
                        default: reader.SkipArray(); break;
                    }
                }
                else if (reader.Token == JsonToken.ObjectStart)
                {
                    switch (prop)
                    {
                        case "constructor": 
                            MemberModel ctor = ReadMethod(reader, cClass);
                            cClass.Constructor = ctor.Name;
                            break;
                        default: reader.SkipObject(); break;
                    }
                }
            }

            if (cFile.FileName == null) return;
            string key = cFile.FileName.ToUpper();
            if (files.ContainsKey(key)) cFile = files[key];
            else files.Add(key, cFile);

            if (cFile.Package.ToLower() == "system") // System classes tweaks
            {
                cFile.Package = "";
                if (cClass.Name == "Vector") cClass.Name = "Vector.<T>";
                if (cClass.Name == "Object") cClass.ExtendsType = "void";
            }
            if (cClass.Access == Visibility.Private) cClass.Access = Visibility.Public;

            if (cDelegate.Name != null)
            {
                if (cDelegate.Parameters == null) cDelegate.Parameters = new List<MemberModel>();
                cDelegate.Access = Visibility.Public;
                cDelegate.Flags = FlagType.Function | FlagType.Delegate;
                cDelegate.InFile = cFile;
                cDelegate.IsPackageLevel = true;
                cFile.Members.Add(cDelegate);
            }
            else
            {
                cClass.Type = CleanType(String.IsNullOrEmpty(cFile.Package) ? cClass.Name : cFile.Package + "." + cClass.Name);
                cClass.InFile = cFile;
                cFile.Classes.Add(cClass);
            }
        }
Пример #59
0
        static public void GenerateJob(GeneratorJobType job, MemberModel member, ClassModel inClass, string itemLabel, Object data)
        {
            ScintillaNet.ScintillaControl Sci = ASContext.CurSciControl;
            lookupPosition = Sci.CurrentPos;

            int position;
            MemberModel latest = null;
            bool detach = true;
            switch (job)
            {
                case GeneratorJobType.Getter:
                case GeneratorJobType.Setter:
                case GeneratorJobType.GetterSetter:
                    GenerateProperty(job, member, inClass, Sci);
                    break;

                case GeneratorJobType.BasicEvent:
                case GeneratorJobType.ComplexEvent:

                    latest = TemplateUtils.GetTemplateBlockMember(Sci,
                        TemplateUtils.GetBoundary("EventHandlers"));
                    if (latest == null)
                    {
                        if (ASContext.CommonSettings.MethodsGenerationLocations == MethodsGenerationLocations.AfterSimilarAccessorMethod)
                            latest = GetLatestMemberForFunction(inClass, GetDefaultVisibility(), member);
                        if (latest == null)
                            latest = member;
                    }

                    position = Sci.PositionFromLine(latest.LineTo + 1) - ((Sci.EOLMode == 0) ? 2 : 1);
                    Sci.SetSel(position, position);
                    string type = contextParam;
                    if (job == GeneratorJobType.BasicEvent)
                        if (itemLabel.IndexOf("DataEvent") >= 0) type = "DataEvent"; else type = "Event";
                    GenerateEventHandler(contextToken, type, member, position);
                    break;

                case GeneratorJobType.Delegate:
                    position = Sci.PositionFromLine(member.LineTo + 1) - ((Sci.EOLMode == 0) ? 2 : 1);
                    Sci.SetSel(position, position);
                    GenerateDelegateMethod(contextToken, member, position);
                    break;

                case GeneratorJobType.Constant:
                case GeneratorJobType.Variable:
                case GeneratorJobType.VariablePublic:
                    Sci.BeginUndoAction();
                    try
                    {
                        GenerateVariableJob(job, Sci, member, detach, inClass);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.Function:
                case GeneratorJobType.FunctionPublic:
                    Sci.BeginUndoAction();
                    try
                    {
                        GenerateFunctionJob(job, Sci, member, detach, inClass);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.ImplementInterface:
                    ClassModel aType = ASContext.Context.ResolveType(contextParam, ASContext.Context.CurrentModel);
                    if (aType.IsVoid()) return;

                    latest = GetLatestMemberForFunction(inClass, Visibility.Public, null);
                    if (latest == null)
                        latest = FindLatest(0, 0, inClass, false, false);

                    if (latest == null) return;

                    position = Sci.PositionFromLine(latest.LineTo + 1) - ((Sci.EOLMode == 0) ? 2 : 1);
                    Sci.SetSel(position, position);
                    GenerateImplementation(aType, position);
                    break;

                case GeneratorJobType.MoveLocalUp:
                    Sci.BeginUndoAction();
                    try
                    {
                        if (!RemoveLocalDeclaration(Sci, contextMember)) return;

                        position = GetBodyStart(member.LineFrom, member.LineTo, Sci);
                        Sci.SetSel(position, position);

                        string varType = contextMember.Type;
                        if (varType == "") varType = null;

                        string template = TemplateUtils.GetTemplate("Variable");
                        template = TemplateUtils.ReplaceTemplateVariable(template, "Name", contextMember.Name);
                        template = TemplateUtils.ReplaceTemplateVariable(template, "Type", varType);
                        template = TemplateUtils.ReplaceTemplateVariable(template, "Modifiers", null);
                        template = TemplateUtils.ReplaceTemplateVariable(template, "Value", null);
                        template += "\n$(Boundary)";

                        lookupPosition += SnippetHelper.InsertSnippetText(Sci, position, template);

                        Sci.SetSel(lookupPosition, lookupPosition);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.PromoteLocal:
                    Sci.BeginUndoAction();
                    try
                    {
                        if (!RemoveLocalDeclaration(Sci, contextMember)) return;

                        latest = GetLatestMemberForVariable(GeneratorJobType.Variable, inClass, GetDefaultVisibility(), member);
                        if (latest == null) return;

                        position = FindNewVarPosition(Sci, inClass, latest);
                        if (position <= 0) return;
                        Sci.SetSel(position, position);

                        contextMember.Flags -= FlagType.LocalVar;
                        if ((member.Flags & FlagType.Static) > 0)
                            contextMember.Flags |= FlagType.Static;
                        contextMember.Access = GetDefaultVisibility();
                        GenerateVariable(contextMember, position, detach);

                        Sci.SetSel(lookupPosition, lookupPosition);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.AddAsParameter:
                    Sci.BeginUndoAction();
                    try
                    {
                        AddAsParameter(inClass, Sci, member, detach);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    
                    break;

                case GeneratorJobType.AddImport:
                    position = Sci.CurrentPos;
                    if ((member.Flags & (FlagType.Class | FlagType.Enum | FlagType.Struct | FlagType.TypeDef)) == 0)
                    {
                        if (member.InFile == null) break;
                        member.Type = member.Name;
                    }
                    Sci.BeginUndoAction();
                    try
                    {
                        int offset = InsertImport(member, true);
                        position += offset;
                        Sci.SetSel(position, position);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.Class:
                    String clasName = Sci.GetWordFromPosition(Sci.CurrentPos);
                    GenerateClass(Sci, clasName, inClass);
                    break;

                case GeneratorJobType.Constructor:
                    member = new MemberModel(inClass.Name, inClass.QualifiedName, FlagType.Constructor | FlagType.Function, Visibility.Public);
                    GenerateFunction(
                        member,
                        Sci.CurrentPos, false, inClass);
                    break;

                case GeneratorJobType.ToString:
                    Sci.BeginUndoAction();
                    try
                    {
                        GenerateToString(inClass, Sci, member);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.FieldFromPatameter:
                    Sci.BeginUndoAction();
                    try
                    {
                        GenerateFieldFromParameter(Sci, member, inClass, (Visibility)(((Hashtable)data)["scope"]));
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.AddInterfaceDef:
                    Sci.BeginUndoAction();
                    try
                    {
                        AddInterfaceDefJob(inClass, Sci, member, (String)data);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.ConvertToConst:
                    Sci.BeginUndoAction();
                    try
                    {
                        ConvertToConst(inClass, Sci, member, detach);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.ChangeMethodDecl:
                    Sci.BeginUndoAction();
                    try
                    {
                        ChangeMethodDecl(Sci, member, inClass);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.ChangeConstructorDecl:
                    Sci.BeginUndoAction();
                    try
                    {
                        ChangeConstructorDecl(Sci, member, inClass);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.EventMetatag:
                    Sci.BeginUndoAction();
                    try
                    {
                        EventMetatag(inClass, Sci, member);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;

                case GeneratorJobType.AssignStatementToVar:
                    Sci.BeginUndoAction();
                    try
                    {
                        AssignStatementToVar(inClass, Sci, member);
                    }
                    finally
                    {
                        Sci.EndUndoAction();
                    }
                    break;
            }
        }
Пример #60
0
 static public void SetJobContext(String contextToken, String contextParam, MemberModel contextMember, Match contextMatch)
 {
     ASGenerator.contextToken = contextToken;
     ASGenerator.contextParam = contextParam;
     ASGenerator.contextMember = contextMember;
     ASGenerator.contextMatch = contextMatch;
 }