public ContentResult Action()
        {
            string strRequest = _appLoader.get_PostData(HttpContext.Request);

            try
            {
                if (string.IsNullOrEmpty(strRequest))
                {
                    return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Request_Invalidate], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Request_Invalidate])));
                }
                XmlDocument requestDoc = new XmlDocument();
                requestDoc.LoadXml(strRequest);
                XmlNode typeNode   = requestDoc.SelectSingleNode("/root/type");
                XmlNode actionNode = requestDoc.SelectSingleNode("/root/action");
                XmlNode codeNode   = requestDoc.SelectSingleNode("/root/code");
                string  str_code   = Util_XmlOperHelper.GetNodeValue(codeNode);
                string  str_action = Util_XmlOperHelper.GetNodeValue(actionNode);
                string  str_type   = Util_XmlOperHelper.GetNodeValue(typeNode);
                Dictionary <string, string> paramsmap = new Dictionary <string, string>();
                string uname = GetAccountInfoFromBasicController("name");
                paramsmap.Add("@uid", uname);
                paramsmap.Add("@rdt", DateTime.Now.ToString("yyyy-MM-dd"));
                paramsmap.Add("@actions", str_action);
                paramsmap.Add("@code", str_code);
                paramsmap.Add("@type", str_type);
                DataTable dtLearning = _appLoader.ExecuteSelectWithMixedConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_learninrecord, paramsmap);
                if (dtLearning != null)
                {
                    if (dtLearning.Rows.Count >= 1)
                    {
                        int    times = Data_dbDataHelper.GetColumnIntData(dtLearning.Rows[0], "times");
                        string id    = string.Empty;
                        Data_dbDataHelper.GetColumnData(dtLearning.Rows[0], "id", out id);
                        paramsmap.Add("@times", (times++).ToString());
                        paramsmap.Add("@rtime", DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
                        paramsmap.Add("@rfultime", DateTime.Now.ToString());
                        paramsmap.Add("@id", id);
                        _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_learninrecord, paramsmap);
                        return(Content(MessageHelper.ExecuteSucessful()));
                    }
                }
                paramsmap.Add("@times", "1");
                paramsmap.Add("@rtime", DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
                paramsmap.Add("@rfultime", DateTime.Now.ToString());
                _appLoader.ExecuteInsert(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_learninrecord, paramsmap);
                return(Content(MessageHelper.ExecuteSucessful()));
            }
            catch
            {
                return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Fetch_Error], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Fetch_Error])));
            }
        }
        public bool VerifyToken()
        {
            string token = _appLoader.get_ClientToken(Request, SYBOL_TOKEN_BASIC);

            if (token == string.Empty)
            {
                return(false);
            }
            else
            {
                try
                {
                    Util_NetServices netObj    = new Util_NetServices();
                    string           result    = netObj.RequestWithGet(ROOT_SERVER + "Account_Students_SignStatus?" + SYBOL_TOKEN_BASIC + "=" + token).ToString();
                    XmlDocument      resultDoc = new XmlDocument();
                    resultDoc.LoadXml(result);
                    XmlNode executedNode = resultDoc.SelectSingleNode("/root/executed");
                    if (executedNode != null)
                    {
                        if (Util_XmlOperHelper.GetNodeValue(executedNode) == "true")
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch
                {
                    return(false);
                }
            }
        }
Example #3
0
        private string ProcessProtocal(string token, string message, AppLoader existedLoader, out string refAction)
        {
            refAction = "";
            XmlDocument protocalMessageDoc = new XmlDocument();

            protocalMessageDoc.LoadXml(message);
            XmlNode fromNode = protocalMessageDoc.SelectSingleNode("/root/from");

            if (fromNode == null)
            {
                return("<root type='error'><errmsg>nofrom</errmsg></root>");
            }
            string from = Util_XmlOperHelper.GetNodeValue(fromNode);

            /*if(from != token)
             *      return "<root type='error'><errmsg>invalidated token</errmsg></root>";*/
            XmlNode actionNode = protocalMessageDoc.SelectSingleNode("/root/action");

            if (actionNode == null)
            {
                return("<root type='error'><errmsg>noaction</errmsg></root>");
            }
            string  action     = Util_XmlOperHelper.GetNodeValue(actionNode);
            XmlNode paramsNode = protocalMessageDoc.SelectSingleNode("/root/params");

            refAction = action;
            Global.ItemAccountStudents activeStuentItem = Global.LoginServices.Pull(token);
            switch (action)
            {
            case Global.ActionsMap.Action_Get_DialogList:
                /*
                 * <root>
                 * <from>
                 * token
                 * <from>
                 * <action>
                 * Action_Get_DialogList
                 * </action>
                 * </root>
                 *
                 */
                return(Action_Get_DialogList(activeStuentItem.name, existedLoader));

            case Global.ActionsMap.Action_Get_DialogContent:
                /*
                 * <root>
                 * <from>
                 * token
                 * </from>
                 * <symbol>
                 * </symbol>
                 * <action>
                 * Action_Get_DialogContent
                 * </action>
                 * </root>
                 *
                 */
                string  message_symbol    = string.Empty;
                XmlNode messageSymbolNode = protocalMessageDoc.SelectSingleNode("/root/symbol");
                if (messageSymbolNode == null)
                {
                    return("<root type='error'><errmsg>nosymbol</errmsg></root>");
                }
                message_symbol = Util_XmlOperHelper.GetNodeValue(messageSymbolNode);
                if (string.IsNullOrEmpty(message_symbol))
                {
                    return("<root type='error'><errmsg>nosymbol</errmsg></root>");
                }
                return(Action_Get_DialogContent(message_symbol, existedLoader));

            case Global.ActionsMap.Action_Set_NewDialog:
                /*
                 * <root>
                 * <from>
                 * token
                 * </from>
                 * <target>
                 * <item>
                 * u1
                 * </item>
                 * <item>
                 * u2
                 * </item>
                 * </target>
                 * <action>
                 * Action_Set_NewDialog
                 * </action>
                 * </root>
                 *
                 */
                XmlNodeList   targetUserNodes = protocalMessageDoc.SelectNodes("/root/target/item");
                List <string> lstTargetItems  = new List <string>();
                if (targetUserNodes != null && targetUserNodes.Count > 0)
                {
                    foreach (XmlNode itemNode in targetUserNodes)
                    {
                        string value = Util_XmlOperHelper.GetNodeValue(itemNode);
                        lstTargetItems.Add(value);
                    }
                }
                else
                {
                    return("<root type='error'><errmsg>notargets</errmsg></root>");
                }
                Global.ItemAccountStudents activeItem = Global.LoginServices.Pull(token);
                lstTargetItems.Add(activeItem.name);
                return(Action_Set_NewDialog(token, lstTargetItems, existedLoader));

            case Global.ActionsMap.Action_Get_RelationsList:
                /*
                 * <root>
                 * <from>
                 * token
                 * </from>
                 * <action>
                 * Action_Get_RelationsList
                 * </action>
                 * </root>
                 */
                return(Action_Get_RelationsList(from, existedLoader));

            case Global.ActionsMap.Action_Get_RelationsSearch:
                /*
                 * <root>
                 * <from>
                 * token
                 * </from>
                 * <action>
                 * Action_Get_RelationsSearch
                 * </action>
                 * <value>
                 * </value>
                 * </root>
                 */
                string  keyvalue  = string.Empty;
                XmlNode valueNode = protocalMessageDoc.SelectSingleNode("/root/value");
                if (valueNode != null)
                {
                    keyvalue = Util_XmlOperHelper.GetNodeValue(valueNode);
                }
                return(Action_Get_RelationsSearch(keyvalue, existedLoader));

            case Global.ActionsMap.Action_Get_RelationsAcceptableList:
                return(Action_Get_RelationsAcceptableList(token, existedLoader));

            case Global.ActionsMap.Action_Set_NewFriend:
                /*
                 * <root>
                 * <from>
                 * token
                 * </from>
                 * <action>
                 * Action_Set_NewFriend
                 * </action>
                 * <msg>
                 * </msg>
                 * <suname>
                 * </suname>
                 * </root>
                 */
                string  suname     = string.Empty;
                XmlNode sunameNode = protocalMessageDoc.SelectSingleNode("/root/suname");
                string  msg        = string.Empty;
                XmlNode msgNode    = protocalMessageDoc.SelectSingleNode("/root/msg");
                if (sunameNode == null)
                {
                    return("<root type='error'><errmsg>nosuname</errmsg></root>");
                }
                else
                {
                    suname = Util_XmlOperHelper.GetNodeValue(sunameNode);
                    return(Action_Set_NewFriend(from, suname, msg, existedLoader));
                }

            case Global.ActionsMap.Action_Set_AcceptFriend:
                /*
                 * <root>
                 * <from>
                 * token
                 * </from>
                 * <action>
                 * Action_Set_AcceptFriend
                 * </action>
                 * <id>
                 * </id>
                 * </root>
                 */
                string  id      = string.Empty;
                XmlNode id_node = protocalMessageDoc.SelectSingleNode("/root/id");
                if (id_node == null)
                {
                    return("<root type='error'><errmsg>no puname</errmsg></root>");
                }
                else
                {
                    id = Util_XmlOperHelper.GetNodeValue(id_node);
                }
                return(Action_Set_AcceptFriend(id, existedLoader));

            case Global.ActionsMap.Action_Get_BatchArrProfile:
                /*
                 * <root>
                 * <from>
                 * token
                 * </from>
                 * <action>
                 * Action_Get_BatchArrProfile
                 * </action>
                 * <params>
                 * <item>
                 * </item>
                 * </params>
                 * </root>
                 */
                List <string> lstID = new List <string>();
                XmlNodeList   items = paramsNode.SelectNodes("item");
                foreach (XmlNode item in items)
                {
                    string itemValue = Util_XmlOperHelper.GetNodeValue(item);
                    lstID.Add(itemValue);
                }
                return(Action_Get_BatchArrProfile(lstID, existedLoader));

            case Global.ActionsMap.Action_Set_SendMessage:
                /*
                 * <root>
                 * <from>
                 * token
                 * </from>
                 * <symbol>
                 * symbol for message
                 * </symbol>
                 * <action>
                 * Action_Set_OpenDialog
                 * </action>
                 * <target>
                 * <item>
                 * u1
                 * </item>
                 * <item>
                 * u2
                 * </item>
                 * </target>
                 * <message>
                 * </message>
                 * </root>
                 *
                 */
                XmlNode symbolNode = protocalMessageDoc.SelectSingleNode("/root/symbol");
                if (symbolNode == null)
                {
                    return("<root type='error'><errmsg>nosymbol</errmsg></root>");
                }
                string  symbolValue = Util_XmlOperHelper.GetNodeValue(symbolNode);
                XmlNode targetNode  = protocalMessageDoc.SelectSingleNode("/root/target");
                if (targetNode == null)
                {
                    return("<root type='error'><errmsg>notarget</errmsg></root>");
                }
                string        tagetValue      = Util_XmlOperHelper.GetNodeValue(targetNode);
                XmlNodeList   targetItemNodes = protocalMessageDoc.SelectNodes("/root/target/item");
                List <string> lstOwners       = new List <string>();
                foreach (XmlNode itemNode in targetItemNodes)
                {
                    string value = Util_XmlOperHelper.GetNodeValue(itemNode);
                    lstOwners.Add(value);
                }
                XmlNode messageNode  = protocalMessageDoc.SelectSingleNode("/root/message");
                string  messageValue = Util_XmlOperHelper.GetNodeValue(messageNode);
                return(Action_Set_SendMessage(activeStuentItem.name, symbolValue, messageValue, lstOwners, existedLoader));
            }
            return("");
        }
        public ContentResult Action()
        {
            string requestData = _appLoader.get_PostData(Request);

            if (string.IsNullOrEmpty(requestData))
            {
                return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Request_Invalidate], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Request_Invalidate])));
            }
            else
            {
                XmlDocument requestDoc = new XmlDocument();
                try
                {
                    requestDoc.LoadXml(requestData);
                }
                catch
                {
                    return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Request_Invalidate], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Request_Invalidate])));
                }
                XmlNode codeNode = requestDoc.SelectSingleNode("/root/code");
                XmlNode stepNode = requestDoc.SelectSingleNode("/root/step");
                XmlNode typeNode = requestDoc.SelectSingleNode("/root/type");
                XmlNode docNode  = requestDoc.SelectSingleNode("/root/doc");
                string  str_code = string.Empty;
                string  str_step = string.Empty;
                string  str_type = string.Empty;
                string  str_doc  = string.Empty;
                if (codeNode == null)
                {
                    return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Request_Invalidate], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Request_Invalidate])));
                }
                str_code = Util_XmlOperHelper.GetNodeValue(codeNode);
                if (stepNode != null)
                {
                    str_step = Util_XmlOperHelper.GetNodeValue(stepNode);
                }
                if (typeNode != null)
                {
                    str_type = Util_XmlOperHelper.GetNodeValue(typeNode);
                }
                if (docNode != null)
                {
                    str_doc = Util_XmlOperHelper.GetNodeValue(docNode);
                }
                string uname = GetAccountInfoFromBasicController("name");
                Dictionary <string, string> paramsForBasic = new Dictionary <string, string>();
                paramsForBasic.Add("@uid", uname);
                paramsForBasic.Add("@lesson_code", str_code);
                DataTable dtData = _appLoader.ExecuteSelectWithMixedConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_lessonstatus, paramsForBasic);
                paramsForBasic.Add("@current_step", str_step);
                paramsForBasic.Add("@current_statusdoc", str_doc);
                paramsForBasic.Add("@type", str_type);
                paramsForBasic.Add("@recorddt", DateTime.Now.ToString());
                if (dtData != null && dtData.Rows.Count == 1)
                {
                    if (_appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_lessonstatus, paramsForBasic))
                    {
                        return(Content(MessageHelper.ExecuteSucessful()));
                    }
                    else
                    {
                        return(Content(MessageHelper.ExecuteFalse()));
                    }
                }
                else
                {
                    if (_appLoader.ExecuteInsert(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_lessonstatus, paramsForBasic))
                    {
                        return(Content(MessageHelper.ExecuteSucessful()));
                    }
                    else
                    {
                        return(Content(MessageHelper.ExecuteFalse()));
                    }
                }
            }
        }