Example #1
0
        protected override object Value()
        {
            object obj;

            if (isPrefix)
            {
                if (isDecrement)
                {
                    obj = Operator.Decrement(target.Get());
                }
                else
                {
                    obj = Operator.Increment(target.Get());
                }
                target.Set(obj);
            }
            else
            {
                obj = target.Get();
                if (isDecrement)
                {
                    target.Set(Operator.Decrement(obj));
                }
                else
                {
                    target.Set(Operator.Increment(obj));
                }
            }
            return(obj);
        }
Example #2
0
 public override void OnExecute()
 {
     if (!body.isAssigned)
     {
         throw new System.Exception("body is unassigned");
     }
     if (HasCoroutineInFlow(body))
     {
         owner.StartCoroutine(OnUpdate(), this);
     }
     else
     {
         using (var val = target.Get <System.IDisposable>()) {
             value = val;
             Node      n;
             WaitUntil w;
             if (!body.ActivateFlowNode(out n, out w))
             {
                 throw new System.Exception("body is not coroutine but body is not finished.");
             }
             if (n != null)
             {
                 jumpState = n.GetJumpState();
                 if (jumpState != null)
                 {
                     Finish();
                     return;
                 }
             }
         }
         Finish(onFinished);
     }
 }
Example #3
0
 protected override void OnExecute()
 {
     if (buttonName.isAssigned && storeValue.isAssigned)
     {
         storeValue.Set(GetButton(buttonName.Get <string>()));
     }
 }
Example #4
0
 protected override void OnExecute()
 {
     if (target.isAssigned && type.isAssigned && storeResult.isAssigned)
     {
         storeResult.Set(Operator.Convert(target.Get(), type.Get <System.Type>()));
     }
 }
Example #5
0
        public override void OnExecute()
        {
            currentTime = 0;
            AnimationCurve c = curve.Get <AnimationCurve>();

            endTime = c.keys[c.length - 1].time;
            owner.StartCoroutine(OnCall(), this);
        }
Example #6
0
 protected override object Value()
 {
     System.Type type = returnType.Get <System.Type>();
     if (type != null)
     {
         if (type == typeof(void))
         {
             return(CustomDelegate.CreateActionDelegate((obj) => {
                 if (owner == null)
                 {
                     return;
                 }
                 for (int i = 0; i < parameterValues.Count; i++)
                 {
                     parameterValues[i] = obj[i];
                 }
                 body.InvokeFlow();
             }, parameterTypes.Select((item) => item.Get <System.Type>()).ToArray()));
         }
         else
         {
             System.Type[] types = new System.Type[parameterTypes.Count + 1];
             for (int x = 0; x < parameterTypes.Count; x++)
             {
                 types[x] = parameterTypes[x].Get <System.Type>();
             }
             types[types.Length - 1] = type;
             return(CustomDelegate.CreateFuncDelegate((obj) => {
                 if (owner == null)
                 {
                     return null;
                 }
                 for (int i = 0; i < parameterValues.Count; i++)
                 {
                     parameterValues[i] = obj[i];
                 }
                 Node n;
                 WaitUntil w;
                 if (!body.ActivateFlowNode(out n, out w))
                 {
                     throw new System.Exception("Coroutine aren't supported by anonymous function in runtime.");
                 }
                 if (n == null)
                 {
                     throw new System.Exception("No return value");
                 }
                 JumpStatement js = n.GetJumpState();
                 if (js == null || js.jumpType != JumpStatementType.Return || !(js.from is NodeReturn))
                 {
                     throw new System.Exception("No return value");
                 }
                 return (js.from as NodeReturn).GetReturnValue();
             }, types));
         }
     }
     return(null);
 }
Example #7
0
 public override bool CanHaveCoroutine()
 {
     if (returnType != null && returnType.isAssigned)
     {
         System.Type rType = returnType.Get() as System.Type;
         return(rType == typeof(IEnumerable) || rType == typeof(IEnumerator) || rType == typeof(IEnumerator <>) || rType == typeof(IEnumerable <>));
     }
     return(false);
 }
Example #8
0
        private void InitDelegate()
        {
            if (!delegateType.isAssigned)
            {
                return;
            }
            var type = delegateType.Get <System.Type>();

            methodInfo = type.GetMethod("Invoke");
            if (methodInfo.ReturnType == typeof(void))
            {
                m_Delegate = CustomDelegate.CreateActionDelegate((obj) => {
                    if (owner == null)
                    {
                        return;
                    }
                    if (obj != null)
                    {
                        while (parameterValues.Count < obj.Length)
                        {
                            parameterValues.Add(null);
                        }
                        for (int i = 0; i < obj.Length; i++)
                        {
                            parameterValues[i] = obj[i];
                        }
                    }
                    body.InvokeFlow();
                }, methodInfo.GetParameters().Select(i => i.ParameterType).ToArray());
            }
            else
            {
                var types = methodInfo.GetParameters().Select(i => i.ParameterType).ToList();
                types.Add(methodInfo.ReturnType);
                m_Delegate = CustomDelegate.CreateFuncDelegate((obj) => {
                    if (owner == null)
                    {
                        return(null);
                    }
                    if (obj != null)
                    {
                        while (parameterValues.Count < obj.Length)
                        {
                            parameterValues.Add(null);
                        }
                        for (int i = 0; i < obj.Length; i++)
                        {
                            parameterValues[i] = obj[i];
                        }
                    }
                    return(input.Get(methodInfo.ReturnType));
                }, types.ToArray());
            }
            // m_Delegate = ReflectionUtils.ConvertDelegate(m_Delegate, e.EventHandlerType);
        }
Example #9
0
 public override System.Type ReturnType()
 {
     if (targetType.isAssigned)
     {
         try {
             return(targetType.Get <Type>());
         }
         catch { }
     }
     return(typeof(object));
 }
Example #10
0
 public override System.Type ReturnType()
 {
     if (elementType.isAssigned)
     {
         System.Type type = elementType.Get <System.Type>();
         if (type != null)
         {
             return(type.MakeArrayType());
         }
     }
     return(typeof(System.Array));
 }
Example #11
0
 public override void OnExecute()
 {
     if (!HasCoroutineInFlow(body))
     {
         IEnumerable lObj = target.Get() as IEnumerable;
         if (lObj != null)
         {
             foreach (object obj in lObj)
             {
                 if (body == null || !body.isAssigned)
                 {
                     continue;
                 }
                 loopObject = obj;
                 Node      n;
                 WaitUntil w;
                 if (!body.ActivateFlowNode(out n, out w))
                 {
                     throw new System.Exception("body is not coroutine but body is not finished.");
                 }
                 if (n == null)                       //Skip on executing flow input pin.
                 {
                     continue;
                 }
                 JumpStatement js = n.GetJumpState();
                 if (js != null)
                 {
                     if (js.jumpType == JumpStatementType.Continue)
                     {
                         continue;
                     }
                     else
                     {
                         if (js.jumpType == JumpStatementType.Return)
                         {
                             jumpState = js;
                         }
                         break;
                     }
                 }
             }
         }
         else
         {
             Debug.LogError("The target must be IEnumerable");
         }
         Finish(onFinished);
     }
     else
     {
         owner.StartCoroutine(OnUpdate(), this);
     }
 }
Example #12
0
 public override void OnExecute()
 {
     if (!hasInitialize)
     {
         if (targetArray.type.IsArray)
         {
             Item.Type = targetArray.type.GetElementType();
         }
         else
         {
             Item.Type = targetArray.type.GetGenericArguments()[0];
         }
         hasInitialize = true;
     }
     if (IsCoroutine())
     {
         owner.StartCoroutine(OnUpdate(), this);
     }
     else
     {
         object tObj = targetArray.Get();
         if (targetArray.type.IsGenericType || targetArray.type.IsArray)
         {
             IEnumerable lObj = tObj as IEnumerable;
             foreach (object obj in lObj)
             {
                 Item.Set(obj);
                 JumpStatement js = nodeToExecute.ActivateAndFindJumpState();
                 if (js != null)
                 {
                     if (js.jumpType == JumpStatementType.Continue)
                     {
                         continue;
                     }
                     else
                     {
                         if (js.jumpType == JumpStatementType.Return)
                         {
                             jumpState = js;
                         }
                         break;
                     }
                 }
             }
         }
         else
         {
             throw new System.Exception("The target array must be array list or generic list");
         }
         Finish();
     }
 }
Example #13
0
 protected override void OnExecute()
 {
     if (axisName.isAssigned && storeValue.isAssigned)
     {
         if (storeValue.type == typeof(int))
         {
             storeValue.Set((int)Input.GetAxis(axisName.Get <string>()));
         }
         else
         {
             storeValue.Set(Input.GetAxis(axisName.Get <string>()));
         }
     }
 }
Example #14
0
 public override System.Type ReturnType()
 {
     if (type.isAssigned)
     {
         try {
             System.Type t = type.Get <System.Type>();
             if (!object.ReferenceEquals(t, null))
             {
                 return(t);
             }
         }
         catch { }
     }
     return(typeof(object));
 }
        protected override void OnExecute()
        {
            GameObject go = null;

            if (objectName.isAssigned)
            {
                go = new GameObject(objectName.Get <string>());
            }
            else
            {
                go = new GameObject();
            }
            if (useTransform)
            {
                go.transform.position    = transform.GetValue <Transform>().position;
                go.transform.eulerAngles = transform.GetValue <Transform>().eulerAngles;
            }
            else
            {
                go.transform.position    = position.GetValue <Vector3>();
                go.transform.eulerAngles = rotation.GetValue <Vector3>();
            }
            if (storeResult.isAssigned)
            {
                storeResult.Set(go);
            }
        }
Example #16
0
        protected override object Value()
        {
            if (!target.isAssigned)
            {
                throw new Exception("target is unassigned");
            }
            object val = target.Get();

            if (object.ReferenceEquals(val, null))
            {
                throw new Exception("value is null");
            }
            for (int i = 0; i < values.Count; i++)
            {
                MemberData member = values[i];
                if (member == null || !member.isAssigned)
                {
                    continue;
                }
                object mVal = member.Get();
                if (mVal.Equals(val))
                {
                    return(targetNodes[i].Get());
                }
            }
            return(defaultTarget.Get());
        }
        public ActionResult CheckIsMemberName(string str)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            MemberData md = new MemberData();
            if (str != "")
            {
                var data = md.Get().ToList().Where(a => a.uName == str && (a.FacebookId == "" && a.GoogleId == ""));
                if (data.Count() > 0)
                {
                    dic.Add("success", true);
                    dic.Add("msg", "OK");
                }
                else
                {
                    dic.Add("success", false);
                    dic.Add("msg", "查無此姓名");
                }

            }
            else
            {
                dic.Add("success", false);
                dic.Add("msg", "Error");
            }

            return Json(dic);
        }
Example #18
0
        public override Object CreateAsset()
        {
            var graph = CreateClassAsset();
            var data  = graph.gameObject.AddComponent <uNodeData>();

            data.Namespace = graphNamespaces;
            data.generatorSettings.usingNamespace = graphUsingNamespaces.ToArray();
            CreateOverrideMembers(graph);
            graph.Attributes = new AttributeData[] {
                new AttributeData()
                {
                    type  = MemberData.CreateFromType(typeof(CustomEditor)),
                    value = new ValueData()
                    {
                        typeData = MemberData.CreateFromType(typeof(CustomEditor)),
                        value    = new ConstructorValueData()
                        {
                            typeData   = MemberData.CreateFromType(typeof(CustomEditor)),
                            parameters = new[] {
                                new ParameterValueData()
                                {
                                    name     = "inspectedType",
                                    typeData = MemberData.CreateFromType(typeof(Type)),
                                    value    = editorType.Get <Type>()
                                }
                            }
                        },
                    },
                }
            };
            return(graph);
        }
Example #19
0
 protected override void OnExecute()
 {
     if (target.isAssigned && type.isAssigned && storeResult.isAssigned)
     {
         object t    = target.Get();
         Type   Type = type.Get() as System.Type;
         if (object.ReferenceEquals(t, null) && (!Type.IsValueType || Nullable.GetUnderlyingType(Type) != null) ||
             !object.ReferenceEquals(t, null) && Type.IsAssignableFrom(t.GetType()))
         {
             storeResult.Set(t);
             return;
         }
         Type = Nullable.GetUnderlyingType(Type) ?? Type;
         storeResult.Set(System.Convert.ChangeType(t, Type));
     }
 }
Example #20
0
        public override void OnExecute()
        {
            if (target == null || !target.isAssigned)
            {
                return;
            }
            object val = target.Get();

            if (object.ReferenceEquals(val, null))
            {
                return;
            }
            for (int i = 0; i < values.Count; i++)
            {
                MemberData member = values[i];
                if (member == null || !member.isAssigned)
                {
                    continue;
                }
                object mVal = member.Get();
                if (mVal.Equals(val))
                {
                    Finish(targetNodes[i], onFinished);
                    return;
                }
            }
            Finish(defaultTarget, onFinished);
        }
Example #21
0
 /// <summary>
 /// Get the inherith type.
 /// </summary>
 /// <returns></returns>
 public override Type GetInheritType()
 {
     if (inheritFrom != null && inheritFrom.isAssigned)
     {
         return(inheritFrom.Get <Type>() ?? typeof(object));
     }
     return(typeof(object));
 }
Example #22
0
 protected override object Value()
 {
     if (condition.isAssigned)
     {
         return(condition.GetValue <bool>() ? onTrue.Get() : onFalse.Get());
     }
     throw new System.Exception();
 }
Example #23
0
 public override void OnExecute()
 {
     if (!HasCoroutineInFlow(body))
     {
         for (index = startIndex.Get(); uNodeHelper.OperatorComparison(index, compareNumber.Get(), compareType);
              uNodeHelper.SetObject(ref index, iteratorSetValue.Get(), iteratorSetType))
         {
             if (!body.isAssigned)
             {
                 continue;
             }
             Node      n;
             WaitUntil w;
             if (!body.ActivateFlowNode(out n, out w))
             {
                 throw new System.Exception("body is not coroutine but body is not finished.");
             }
             if (n == null)                   //Skip on executing flow input pin.
             {
                 continue;
             }
             JumpStatement js = n.GetJumpState();
             if (js != null)
             {
                 if (js.jumpType == JumpStatementType.Continue)
                 {
                     continue;
                 }
                 else
                 {
                     if (js.jumpType == JumpStatementType.Return)
                     {
                         jumpState = js;
                     }
                     break;
                 }
             }
         }
         Finish(onFinished);
     }
     else
     {
         owner.StartCoroutine(OnUpdate(), this);
     }
 }
Example #24
0
        protected override object Value()
        {
            var value = target.Get();

            System.Type t = type.Get <System.Type>();
            if (value != null)
            {
                if (value.GetType() == t)
                {
                    return(value);
                }
                if (t.IsInterface || t.IsCastableTo(typeof(Component)))
                {
                    if (value is GameObject gameObject)
                    {
                        if (t is RuntimeType)
                        {
                            switch (getComponentKind)
                            {
                            case GetComponentKind.GetComponent:
                                return(gameObject.GetGeneratedComponent(t as RuntimeType));

                            case GetComponentKind.GetComponentInChildren:
                                return(gameObject.GetGeneratedComponentInChildren(t as RuntimeType, includeInactive));

                            case GetComponentKind.GetComponentInParent:
                                return(gameObject.GetGeneratedComponentInParent(t as RuntimeType, includeInactive));
                            }
                        }
                        return(gameObject.GetComponent(t));
                    }
                    else if (value is Component component)
                    {
                        if (t is RuntimeType)
                        {
                            switch (getComponentKind)
                            {
                            case GetComponentKind.GetComponent:
                                return(component.GetGeneratedComponent(t as RuntimeType));

                            case GetComponentKind.GetComponentInChildren:
                                return(component.GetGeneratedComponentInChildren(t as RuntimeType, includeInactive));

                            case GetComponentKind.GetComponentInParent:
                                return(component.GetGeneratedComponentInParent(t as RuntimeType, includeInactive));
                            }
                        }
                        return(component.GetComponent(t));
                    }
                }
                else
                {
                    throw new System.InvalidOperationException("The type is not supported to use GetComponent: " + t.FullName);
                }
            }
            return(value);
        }
Example #25
0
 protected override void OnExecute()
 {
     if (!useIndex)
     {
         UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName.Get <string>(), loadMode);
     }
     else
     {
         UnityEngine.SceneManagement.SceneManager.LoadScene(sceneBuildIndex.GetValue <int>(), loadMode);
     }
 }
Example #26
0
 protected override object Value()
 {
     if (unscaledTime)
     {
         if (input.isAssigned)
         {
             Type t = input.type;
             return(Operator.Multiply(input.Get(), Time.unscaledDeltaTime));
         }
         return(1 * Time.unscaledDeltaTime);
     }
     else
     {
         if (input.isAssigned)
         {
             Type t = input.type;
             return(Operator.Multiply(input.Get(), Time.deltaTime));
         }
         return(1 * Time.deltaTime);
     }
 }
 protected override void OnExecute()
 {
     if (gameObject.isAssigned && componentType.isAssigned)
     {
         if (storeComponent.isAssigned)
         {
             storeComponent.Set(gameObject.GetValue <GameObject>().AddComponent(componentType.Get() as System.Type));
             return;
         }
         gameObject.GetValue <GameObject>().AddComponent(componentType.Get() as System.Type);
     }
 }
Example #28
0
 public override void OnExecute()
 {
     if (IsCoroutine())
     {
         owner.StartCoroutine(OnUpdate(), this);
     }
     else
     {
         if (startIndex.isAssigned && compareNumber.isAssigned)
         {
             for (var index = startIndex.Get();
                  uNodeHelper.OperatorComparison(index, compareNumber.Get(), compareType);
                  uNodeHelper.SetObject(ref index, iteratorSetValue.Get(), iteratorSetType))
             {
                 Item.Set(index);
                 JumpStatement js = nodeToExecute.ActivateAndFindJumpState();
                 if (js != null)
                 {
                     if (js.jumpType == JumpStatementType.Continue)
                     {
                         continue;
                     }
                     else
                     {
                         if (js.jumpType == JumpStatementType.Return)
                         {
                             jumpState = js;
                         }
                         break;
                     }
                 }
             }
         }
         else
         {
             throw new System.Exception("The target array must be array list or generic list");
         }
         Finish();
     }
 }
Example #29
0
        protected override object Value()
        {
            var value = target.Get();

            System.Type t = type.Get <System.Type>();
            if (value != null)
            {
                if (value.GetType() == t)
                {
                    return(value);
                }
                if (t == typeof(string))
                {
                    return(value.ToString());
                }
                else if (t == typeof(GameObject))
                {
                    if (value is Component component)
                    {
                        return(component.gameObject);
                    }
                }
                else if (t.IsCastableTo(typeof(Component)))
                {
                    if (value is GameObject gameObject)
                    {
                        if (t is RuntimeType)
                        {
                            return(gameObject.GetGeneratedComponent(t as RuntimeType));
                        }
                        return(gameObject.GetComponent(t));
                    }
                    else if (value is Component component)
                    {
                        if (t is RuntimeType)
                        {
                            return(component.GetGeneratedComponent(t as RuntimeType));
                        }
                        return(component.GetComponent(t));
                    }
                }
            }
            if (!useASWhenPossible || t is RuntimeType || t.IsValueType)
            {
                value = Operator.Convert(value, t);
            }
            else
            {
                value = Operator.TypeAs(value, t);
            }
            return(value);
        }
Example #30
0
        public override void OnClick(Node source, PortCommandData data, Vector2 mousePosition)
        {
            if (source.owner)
            {
                Undo.SetCurrentGroupName("Promote to local variable");
                Undo.RegisterFullObjectHierarchyUndo(source.owner, "Promote to local variable");
            }
            MemberData   m    = data.member;
            var          root = graph.editorData.selectedRoot;
            VariableData var  = uNodeEditorUtility.AddVariable(type, root.localVariable, root);

            if (m.isAssigned && data.portType != null && !data.portType.IsByRef)
            {
                var.Set(m.Get());
            }
            m.CopyFrom(new MemberData(var, root));
            uNodeGUIUtility.GUIChanged(source.owner);
        }
Example #31
0
 protected override void OnExecute()
 {
     if (vector3Variable.isAssigned)
     {
         Vector3 vec = (Vector3)vector3Variable.Get();
         if (storeX.isAssigned)
         {
             storeX.Set(vec.x);
         }
         if (storeY.isAssigned)
         {
             storeY.Set(vec.y);
         }
         if (storeZ.isAssigned)
         {
             storeZ.Set(vec.z);
         }
     }
 }
        public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
        {
            var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
            if (loginInfo == null)
            {
                return RedirectToAction("Index", "login");
            }
            //若使用者已經有登入資料,請使用此外部登入提供者登入使用者
            if (loginInfo != null)
            {
                var id = new ClaimsIdentity(loginInfo.ExternalIdentity.Claims,
                                            DefaultAuthenticationTypes.ApplicationCookie);

                Session["Account"] = id.GetUserId();
                Session["uname"] = loginInfo.DefaultUserName; //取得用戶名稱
                Session["resAccount"] = loginInfo.Login.LoginProvider;//取得用戶來源

                //var resourceAccount = loginInfo.Login.LoginProvider; 
                //TODO: 驗證邏輯,註冊會員邏輯    
                Member m = new Member();
                MemberData md = new MemberData();
                if (Session["Account"] != null)
                {
                    var memberData = md.Get().ToList().Where(a => a.uAccount == Session["Account"].ToString()).SingleOrDefault();
                    if (memberData == null)
                    {
                        m.uAccount = Session["Account"].ToString();
                        m.uName = loginInfo.DefaultUserName;
                        m.wdate = DateTime.Now;
                        m.udate = DateTime.Now;
                        m.uPassWord = "******";
                        m.uphone = "";
                        m.memberID = DateTime.Now.ToString("yyyyMMdd") + (md.Get().Count + 1).ToString().PadLeft(3, '0');
                        m.isdel = 0;
                        m.sort = 5000;
                        switch (loginInfo.Login.LoginProvider)
                        {
                            case "Facebook":
                                m.FacebookId = id.GetUserId();
                                m.GoogleId = "";
                                m.uemail = loginInfo.Email ?? "";
                                break;
                            case "Google":
                                m.FacebookId = "";
                                m.GoogleId = id.GetUserId();
                                m.uemail = loginInfo.Email;
                                break;
                            default:
                                m.FacebookId = "";
                                m.GoogleId = "";
                                m.uemail = "";
                                break;
                        }


                        md.Create(m);
                        TempData["Congu"] = "已成為會員";
                    }

                }

                //End: 加上你的驗證邏輯,或是註冊會員邏輯
                AuthenticationManager.SignIn(id);

                return RedirectToLocal(returnUrl);
            }
            else
            {
                return RedirectToAction("Index", "login");
            }


            // 若使用者已經有登入資料,請使用此外部登入提供者登入使用者
            //var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
            //switch (result)
            //{
            //    case SignInStatus.Success:
            //        return RedirectToLocal(returnUrl);
            //    case SignInStatus.LockedOut:
            //        return View("Lockout");
            //    case SignInStatus.RequiresVerification:
            //        return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
            //    case SignInStatus.Failure:
            //    default:
            //        // 若使用者沒有帳戶,請提示使用者建立帳戶
            //        ViewBag.ReturnUrl = returnUrl;
            //        ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
            //        return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email });
            //}
        }
        public ActionResult register(string name, string account, string password, string tel)
        {
            Member m = new Member();
            MemberData md = new MemberData();
            var count = md.Get().ToList().Count;

            m.uName = name;
            m.uAccount = account;
            m.uPassWord = PassWordSecurity.Sha384Encode(PassWordSecurity.Sha256Encode(password));
            m.uphone = tel;
            m.isdel = 0;
            m.memberID = DateTime.Now.ToString("yyyyMMdd") + (count + 1).ToString().PadLeft(3, '0');
            m.wdate = DateTime.Now;
            m.udate = DateTime.Now;
            m.sort = 5000;
            m.GoogleId = "";
            m.FacebookId = "";
            m.uemail = account;
            md.Create(m);
            Session["resAccount"] = "natr";
            Session["Account"] = account;
            return RedirectToAction("Index", "Member");
        }
        public ActionResult SendCheckPwdMail(string uname, string loginAccount, string code)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            MemberData md = new MemberData();
            Member m = new Member();
            var data = md.Get().ToList().Where(a => a.uName == uname && a.uemail == loginAccount && (a.FacebookId == "" && a.GoogleId == "")).SingleOrDefault();
            if (data != null)
            {

                m.num = data.num;
                var newPwd = RendomNum.GetRandomString(10);
                m.uPassWord = PassWordSecurity.Sha384Encode(PassWordSecurity.Sha256Encode(newPwd));
                md.UpdatePassword(m);

                dic.Add("success", true);
                dic.Add("msg", "以寄到您的信箱,請自行前往確認");
                SendMailToEveryOne.SendMail(loginAccount, "*****@*****.**", "Funmtb忘記密碼通知", "Funmtb忘記密碼通知", "因個資關係,再麻煩親愛的客戶自行到官網去更改密碼,您的新密碼是:" + newPwd, false);
            }
            else
            {
                dic.Add("success", false);
                dic.Add("msg", "發生錯誤");
            }

            return Json(dic);
        }
        public ActionResult signin(string login_account, string login_password)
        {
            Member m = new Member();
            MemberData md = new MemberData();
            var memberdatacount = md.Get().ToList().Where(a => a.uAccount == login_account && a.uPassWord == PassWordSecurity.Sha384Encode(PassWordSecurity.Sha256Encode(login_password))).Count();
            var memberdata = md.Get().ToList().Where(a => a.uAccount == login_account && a.uPassWord == PassWordSecurity.Sha384Encode(PassWordSecurity.Sha256Encode(login_password))).SingleOrDefault();
            if (memberdatacount > 0)
            {
                TempData["isForgetPwd"] = false;
                Session["resAccount"] = "natr";
                Session["Account"] = memberdata.uAccount;
                Session["uname"] = memberdata.uName;

                return RedirectToAction("Index", "Home");
            }
            else
            {
                TempData["isForgetPwd"] = true;
                return RedirectToAction("Index", "login");
            }
        }
        public JsonResult ToCheckOldPwdMatch(int num, string pwd)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();

            MemberData md = new MemberData();
            var data = md.Get().ToList().Where(a => a.num == num).SingleOrDefault();

            if (data.uPassWord == PassWordSecurity.Sha384Encode(PassWordSecurity.Sha256Encode(pwd)))
            {
                dic.Add("success", true);
                dic.Add("isOldPwd", true);
            }
            else
            {
                dic.Add("success", false);
                dic.Add("isOldPwd", false);
            }

            return Json(dic);
        }
        public ActionResult facebookJsLogin(string resid, string resemail, string resname)
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            Session["Account"] = resid; //取得用戶ID
            Session["uname"] = resname; //取得用戶名稱
            Session["resAccount"] = "Facebook";//取得用戶來源
            Member m = new Member();
            MemberData md = new MemberData();
            if (Session["Account"] != null)
            {
                var memberData = md.Get().ToList().Where(a => a.uAccount == Session["Account"].ToString()).SingleOrDefault();
                if (memberData == null)
                {
                    m.uAccount = Session["Account"].ToString();
                    m.uName = resname;
                    m.wdate = DateTime.Now;
                    m.udate = DateTime.Now;
                    m.uPassWord = "******";
                    m.uphone = "";
                    m.memberID = DateTime.Now.ToString("yyyyMMdd") + (md.Get().Count + 1).ToString().PadLeft(3, '0');
                    m.isdel = 0;
                    m.sort = 5000;
                    m.FacebookId = resid;
                    m.GoogleId = "";
                    m.uemail = resemail ?? "";
                    md.Create(m);

                    dic.Add("Msg", "已成為會員");
                }
                else
                {
                    if (memberData.uemail == "" || memberData.uemail == null)
                    {
                        m.num = memberData.num;
                        m.uemail = resemail;
                        md.UpdateEmail(m);
                    }
                    dic.Add("Msg", "");
                }

            }

            dic.Add("success", true);
            return Json(dic);
        }
 public ActionResult ToMatchAccount(string account)
 {
     Dictionary<string, object> dic = new Dictionary<string, object>();
     MemberData md = new MemberData();
     var membercount = md.Get().ToList().Where(a => a.uAccount == account).Count();
     if (membercount > 0)
     {
         dic.Add("success", false);
     }
     else
     {
         dic.Add("success", true);
     }
     return Json(dic);
 }
        public ActionResult ToUpdateMemberData(int num, string password = "", string new_password = "", string tel = "", string name = "", string Email = "")
        {
            Dictionary<string, object> dic = new Dictionary<string, object>();
            Member m = new Member();
            MemberData md = new MemberData();
            var datacount = md.Get().ToList().Where(a => a.num == num).Count();
            var data = md.Get().ToList().Where(a => a.num == num).FirstOrDefault();
            if (datacount > 0)
            {
                if (password != "")
                {
                    if (data.uPassWord != PassWordSecurity.Sha384Encode(PassWordSecurity.Sha256Encode(password)))
                    {
                        TempData["msg"] = "舊密碼錯誤";
                    }
                    else
                    {
                        m.num = num;
                        m.uPassWord = PassWordSecurity.Sha384Encode(PassWordSecurity.Sha256Encode(new_password));
                        m.uphone = tel;
                        m.uName = name;
                        m.uemail = Email;
                        m.udate = DateTime.Now;
                        md.Update(m);
                        TempData["msg"] = "更新成功";
                    }

                }
                else
                {
                    m.num = num;
                    m.uPassWord = data.uPassWord;
                    m.uphone = tel;
                    m.uName = name;
                    if (Email != "")
                    {
                        m.uemail = Email;
                    }
                    else
                    {
                        m.uemail = data.uemail;
                    }

                    m.udate = DateTime.Now;
                    md.Update(m);
                    TempData["msg"] = "更新成功";
                }

            }
            else
            {
                TempData["msg"] = "不正常管道錯誤";
            }

            return RedirectToAction("Index", "Member");
        }