Пример #1
0
        public string Action_Set_SendMessage(string uid, string messageSymbol, string message, List <string> lstOwners, AppLoader existedLoader)
        {
            foreach (string owner in lstOwners)
            {
                if (_accountTokenMap.ContainsKey(owner))
                {
                    string    owner_token  = _accountTokenMap[owner];
                    WebSocket owner_socket = null;
                    if (_sockets.ContainsKey(owner_token))
                    {
                        owner_socket = _sockets[owner_token];
                        StringBuilder sent_message = new StringBuilder();
                        sent_message.Append("<root>");
                        sent_message.Append("<from>" + uid);
                        sent_message.Append("</from>");
                        sent_message.Append("<group>");
                        sent_message.Append("</group>");
                        sent_message.Append("<action>");
                        sent_message.Append(Global.ActionsMap.Passive_Get_ReceivedMessage);
                        sent_message.Append("</action>");
                        sent_message.Append("<msg>");
                        sent_message.Append(message);
                        sent_message.Append("</msg>");
                        sent_message.Append("</root>");
                        SendStringAsync(owner_socket, message);
                    }
                }
            }
            Dictionary <string, string> activeParams = new Dictionary <string, string>();

            activeParams.Add("symbol", messageSymbol);
            DataTable activeDataTable = existedLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_messages_students, activeParams);

            if (activeDataTable == null)
            {
                return("<root type='error'><errmsg>lostdata</errmsg></root>");
            }
            else
            {
                string base64MsgContent = string.Empty;
                string id = string.Empty;
                Data_dbDataHelper.GetArrByteColumnDataToString(activeDataTable.Rows[0], "content", out base64MsgContent);
                Data_dbDataHelper.GetColumnData(activeDataTable.Rows[0], "id", out id);
                string      MsgContent = Util_Common.Decoder_Base64(base64MsgContent);
                XmlDocument contentDoc = new XmlDocument();
                contentDoc.LoadXml(MsgContent);
                XmlNode newItem = Util_XmlOperHelper.CreateNode(contentDoc, "item", message);
                Util_XmlOperHelper.SetAttribute(newItem, "date", DateTime.Now.ToString("yyyy-MM-dd"));
                Util_XmlOperHelper.SetAttribute(newItem, "time", DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
                Util_XmlOperHelper.SetAttribute(newItem, "dt", DateTime.Now.ToString());
                contentDoc.SelectSingleNode("/msg").AppendChild(newItem);
                string MsgBase64Conetent = Util_Common.Encoder_Base64(contentDoc.OuterXml);
                activeParams.Clear();
                activeParams.Add("id", id);
                activeParams.Add("content", MsgBase64Conetent);
                existedLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_messages_students, activeParams);
                return("<root><msg>sent</msg></root>");
            }
        }
Пример #2
0
 public ContentResult Action()
 {
     try
     {
         XmlDocument resultDoc = new XmlDocument();
         resultDoc.LoadXml("<root></root>");
         string uname = GetAccountInfoFromBasicController("name");
         Dictionary <string, string> paramsForBasic = new Dictionary <string, string>();
         paramsForBasic.Add("@uid", uname);
         DataTable dtData = _appLoader.ExecuteSelectWithMixedConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_course_exp, paramsForBasic);
         if (dtData != null && dtData.Rows.Count > 0)
         {
             DataRow currentRow = null;
             Data_dbDataHelper.GetActiveRow(dtData, 0, out currentRow);
             if (currentRow != null)
             {
                 int       exp_value = Data_dbDataHelper.GetColumnIntData(currentRow, "exp");
                 DataTable dtTitle   = _appLoader.ExecuteSelect(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_titles_defined);
                 if (dtData != null && dtData.Rows.Count > 0)
                 {
                     foreach (DataRow activeRow in dtData.Rows)
                     {
                         string title_name    = string.Empty;
                         string title_titles  = string.Empty;
                         int    title_exp_min = 0;
                         int    title_exp_max = 0;
                         Data_dbDataHelper.GetColumnData(activeRow, "name", out title_name);
                         Data_dbDataHelper.GetColumnData(activeRow, "titles", out title_titles);
                         title_exp_min = Data_dbDataHelper.GetColumnIntData(activeRow, "exp_min");
                         title_exp_max = Data_dbDataHelper.GetColumnIntData(activeRow, "exp_max");
                         if (exp_value >= title_exp_max)
                         {
                             XmlNode itemNode = Util_XmlOperHelper.CreateNode(resultDoc, "item", "");
                             resultDoc.SelectSingleNode("/root").AppendChild(itemNode);
                             Util_XmlOperHelper.SetAttribute(itemNode, "name", title_name);
                             Util_XmlOperHelper.SetAttribute(itemNode, "title", title_titles);
                             Util_XmlOperHelper.SetAttribute(itemNode, "isget", "1");
                         }
                         else
                         {
                             XmlNode itemNode = Util_XmlOperHelper.CreateNode(resultDoc, "item", "");
                             resultDoc.SelectSingleNode("/root").AppendChild(itemNode);
                             Util_XmlOperHelper.SetAttribute(itemNode, "name", title_name);
                             Util_XmlOperHelper.SetAttribute(itemNode, "title", title_titles);
                             Util_XmlOperHelper.SetAttribute(itemNode, "expvalue", exp_value.ToString());
                             Util_XmlOperHelper.SetAttribute(itemNode, "isget", "0");
                         }
                     }
                 }
             }
         }
         return(Content(resultDoc.OuterXml));
     }
     catch
     {
         return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Fetch_Error], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Fetch_Error])));
     }
 }
Пример #3
0
        public XmlDocument createXmlDoc()
        {
            XmlDocument source = new XmlDocument();

            source.LoadXml("<root></root>");
            XmlNode rootNode = source.SelectSingleNode("/root");

            Util_XmlOperHelper.SetAttribute(rootNode, "name", name);
            Util_XmlOperHelper.SetAttribute(rootNode, "regtime", regedtime.ToString());
            Util_XmlOperHelper.SetAttribute(rootNode, "id", id);
            Util_XmlOperHelper.SetAttribute(rootNode, "lastvisited", lastVisted.ToString());
            return(source);
        }
Пример #4
0
 public ContentResult Action()
 {
     try
     {
         string uname = GetAccountInfoFromBasicController("name");
         Dictionary <string, string> paramsMap = new Dictionary <string, string>();
         paramsMap.Add("@uid", uname);
         DataTable     dtData = _appLoader.ExecuteSelectWithConditionsReturnDT(AppMain.Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, AppMain.Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_coursepackage, paramsMap);
         List <string> lstCoursesFromPackage = new List <string>();
         foreach (DataRow activeDR in dtData.Rows)
         {
             string courseid = string.Empty;
             Data_dbDataHelper.GetColumnData(activeDR, "courseid", out courseid);
             string overdate = string.Empty;
             Data_dbDataHelper.GetColumnData(activeDR, "overdate", out overdate);
             DateTime dtOverdate = DateTime.Now;
             DateTime.TryParse(overdate, out dtOverdate);
             if (dtOverdate <= DateTime.Now)
             {
                 lstCoursesFromPackage.Add(courseid);
             }
         }
         XmlDocument returnDoc = new XmlDocument();
         returnDoc.LoadXml("<root></root>");
         dtData = _appLoader.ExecuteSelect(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_course_main);
         foreach (DataRow activeRow in dtData.Rows)
         {
             string course_name = string.Empty;
             Data_dbDataHelper.GetColumnData(activeRow, "name", out course_name);
             string course_id = string.Empty;
             Data_dbDataHelper.GetColumnData(activeRow, "id", out course_id);
             string course_title = string.Empty;
             Data_dbDataHelper.GetColumnData(activeRow, "title", out course_title);
             string course_isfree = string.Empty;
             Data_dbDataHelper.GetColumnData(activeRow, "isfree", out course_isfree);
             if (lstCoursesFromPackage.Contains(course_id) || course_isfree == "1")
             {
                 XmlNode newItemNode = Util_XmlOperHelper.CreateNode(returnDoc, "item", "");
                 Util_XmlOperHelper.SetAttribute(newItemNode, "name", course_name);
                 Util_XmlOperHelper.SetAttribute(newItemNode, "id", course_id);
                 Util_XmlOperHelper.SetAttribute(newItemNode, "title", course_title);
                 returnDoc.SelectSingleNode("/root").AppendChild(newItemNode);
             }
         }
         return(Content(returnDoc.OuterXml));
     }
     catch
     {
         return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Fetch_Error], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Fetch_Error])));
     }
 }
Пример #5
0
 public ContentResult Action()
 {
     try
     {
         XmlDocument messageDoc = new XmlDocument();
         messageDoc.LoadXml("<root></root>");
         XmlNode rootNode = messageDoc.SelectSingleNode("/root");
         XmlNode itemNode = Util_XmlOperHelper.CreateNode(messageDoc, "item", "");
         Util_XmlOperHelper.SetAttribute(itemNode, "MainService", "true");
         rootNode.AppendChild(itemNode);
         try
         {
             _appLoader.InitApiConfigs(Global.GlobalDefines.SY_CONFIG_FILE);
             itemNode = Util_XmlOperHelper.CreateNode(messageDoc, "item", "");
             Util_XmlOperHelper.SetAttribute(itemNode, "InitService", "true");
             rootNode.AppendChild(itemNode);
         }
         catch
         {
             itemNode = Util_XmlOperHelper.CreateNode(messageDoc, "item", "");
             Util_XmlOperHelper.SetAttribute(itemNode, "InitService", "false");
             rootNode.AppendChild(itemNode);
         }
         try
         {
             _appLoader.ConnectDB(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN);
             itemNode = Util_XmlOperHelper.CreateNode(messageDoc, "item", "");
             Util_XmlOperHelper.SetAttribute(itemNode, "ConnectDBService", "true");
             rootNode.AppendChild(itemNode);
         }
         catch
         {
             itemNode = Util_XmlOperHelper.CreateNode(messageDoc, "item", "");
             Util_XmlOperHelper.SetAttribute(itemNode, "ConnectDBService", "false");
             rootNode.AppendChild(itemNode);
         }
         return(Content(messageDoc.OuterXml));
     }
     catch
     {
         return(Content(MessageHelper.ExecuteFalse()));
     }
     finally
     {
         _appLoader.CloseDB();
     }
 }
        public ContentResult action()
        {
            Dictionary <string, string> paramsmap = new Dictionary <string, string>();
            string uname = GetAccountInfoFromBasicController("name");

            paramsmap.Add("@uid", uname);
            class_data_MySqlDataReader mySqlDataReader = (class_data_MySqlDataReader)_appLoader.ExecuteSelectWithConditionsReturnDR(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_appstudio_store, paramsmap);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<root></root>");
            while (mySqlDataReader.ActiveDataReader.Read())
            {
                XmlNode newItem = Util_XmlOperHelper.CreateNode(doc, "item", "");
                doc.SelectSingleNode("/root").AppendChild(newItem);
                Util_XmlOperHelper.SetAttribute(newItem, "id", mySqlDataReader.ActiveDataReader.GetString("id"));
                Util_XmlOperHelper.SetAttribute(newItem, "pname", mySqlDataReader.ActiveDataReader.GetString("pname"));
                Util_XmlOperHelper.SetAttribute(newItem, "imdt", mySqlDataReader.ActiveDataReader.GetString("imdt"));
            }
            mySqlDataReader.ActiveDataReader.Close();
            return(Content(doc.OuterXml));
        }
Пример #7
0
        public string Action_Get_DialogList(string uid, AppLoader existedLoader)
        {
            string    query_sql       = "SELECT * FROM ikcoder_basic.messagesindex_students where symbol in (select symbol from ikcoder_basic.messagesindex_students where uid = '" + uid + "')";
            DataTable activeDataTable = existedLoader.ExecuteSQL(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, query_sql);

            if (activeDataTable == null)
            {
                return("<root type='error'><errmsg>nodata</errmsg></root>");
            }
            else
            {
                XmlDocument returnDoc = new XmlDocument();
                returnDoc.LoadXml("<root></root>");
                XmlNode rootNode  = returnDoc.SelectSingleNode("/root");
                int     uid_index = 1;
                foreach (DataRow activeRow in activeDataTable.Rows)
                {
                    string strSymbol = string.Empty;
                    Data_dbDataHelper.GetColumnData(activeRow, "symbol", out strSymbol);
                    string uid_fromdb = string.Empty;
                    Data_dbDataHelper.GetColumnData(activeRow, "uid", out uid_fromdb);
                    if (uid == uid_fromdb)
                    {
                        continue;
                    }
                    XmlNode itemNode = returnDoc.SelectSingleNode("/root/item[@symbol='" + strSymbol + "']");
                    if (itemNode == null)
                    {
                        itemNode = Util_XmlOperHelper.CreateNode(returnDoc, "item", "");
                        rootNode.AppendChild(itemNode);
                    }
                    Util_XmlOperHelper.SetAttribute(itemNode, "uid", uid_fromdb);
                    Util_XmlOperHelper.SetAttribute(itemNode, "symbol", strSymbol);
                    Util_XmlOperHelper.SetAttribute(itemNode, "index", uid_index.ToString());
                    uid_index++;
                }
                return(returnDoc.OuterXml.ToString());
            }
        }
Пример #8
0
        public ContentResult Action()
        {
            try
            {
                XmlDocument doc_Result       = new XmlDocument();
                XmlDocument doc_AccountTotal = new XmlDocument();
                doc_Result.LoadXml("<root></root>");
                XmlNode rootNode = doc_Result.SelectSingleNode("/root");
                Util_XmlOperHelper.SetAttribute(rootNode, "gdate", DateTime.Now.ToString("yyyy-MM-dd"));
                string uname = GetAccountInfoFromBasicController("name");
                string uid   = GetAccountInfoFromBasicController("id");

                //Get total count
                doc_AccountTotal = GetAPIFromCoreBasic("Account_Students_TotalCount");
                XmlNode rowNode       = doc_AccountTotal.SelectSingleNode("/root/row[@index='1']");
                string  strTotalValue = Util_XmlOperHelper.GetAttrValue(rowNode, "total");
                int     iTotalValue   = 1;
                int.TryParse(strTotalValue, out iTotalValue);
                if (iTotalValue == 0)
                {
                    iTotalValue = 1;
                }


                //Get exp
                Dictionary <string, string> paramsMap = new Dictionary <string, string>();
                paramsMap.Add("@uid", uname);
                DataTable dtData_Exp    = _appLoader.ExecuteSelectWithConditionsReturnDT(AppMain.Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, AppMain.Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_exp, paramsMap);
                int       totalExpValue = 0;
                foreach (DataRow activeRow in dtData_Exp.Rows)
                {
                    string strExpValueFromDB = string.Empty;
                    Data_dbDataHelper.GetColumnData(activeRow, "exp", out strExpValueFromDB);
                    int iTmpValue = 0;
                    int.TryParse(strExpValueFromDB, out iTmpValue);
                    totalExpValue = totalExpValue + iTmpValue;
                }

                //Get exp postion for all
                string    sql             = "select (@pos:=@pos+1) as pos,tmpResult.* from (SELECT sum(exp) as rexp,uid FROM ikcoder_appmain.students_exp group by uid order by rexp desc) tmpResult,(select @pos:=0) r";
                DataTable dtData_Position = _appLoader.ExecuteSQL(AppMain.Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, sql);
                string    position        = string.Empty;
                if (dtData_Position != null && dtData_Position.Rows.Count > 0)
                {
                    DataRow[] row = dtData_Position.Select("uid='" + uname + "'");

                    if (row.Length == 1)
                    {
                        Data_dbDataHelper.GetColumnData(row[0], "pos", out position);
                    }
                    else
                    {
                        position = "1";
                    }
                }
                int iPosition = 1;
                int.TryParse(position, out iPosition);

                //Get finished lessons
                paramsMap.Clear();
                paramsMap.Add("@uid", uname);
                List <string> lstLessonsFinished_Code = new List <string>();
                List <string> lstLessonsFinished_Name = new List <string>();
                DataTable     dtData_FinishedLesson   = _appLoader.ExecuteSelectWithConditionsReturnDT(AppMain.Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, AppMain.Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_lessonfinished, paramsMap);
                int           iFinishedLessons        = 0;
                if (dtData_FinishedLesson != null && dtData_FinishedLesson.Rows.Count > 0)
                {
                    iFinishedLessons = dtData_FinishedLesson.Rows.Count;
                    foreach (DataRow activeDR in dtData_FinishedLesson.Rows)
                    {
                        string lesson_code = string.Empty;
                        Data_dbDataHelper.GetColumnData(activeDR, "lesson_code", out lesson_code);
                        lstLessonsFinished_Code.Add(lesson_code);
                    }
                }

                //Get achieved defined
                DataTable dtData_Achieved = _appLoader.ExecuteSelect(AppMain.Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, AppMain.Global.MapStoreProcedures.ikcoder_appmain.spa_operation_achieved_defined);

                //Get Lessons Basic
                DataTable dtData_Basic = _appLoader.ExecuteSelect(AppMain.Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, AppMain.Global.MapStoreProcedures.ikcoder_appmain.spa_operation_course_basic);

                //Get Learning Status
                DataTable dtData_LearningStatus = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_learninrecord, paramsMap);

                //Get Course Main
                DataTable dtData_CourseMain = _appLoader.ExecuteSelect(AppMain.Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, AppMain.Global.MapStoreProcedures.ikcoder_appmain.spa_operation_course_main);

                //Get Lessons Total
                sql = "SELECT count(*) as total,course_name FROM ikcoder_appmain.course_basic group by course_name";
                DataTable dtData_LessonsTotal = _appLoader.ExecuteSQL(AppMain.Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, sql);

                //Get Finished Lessons Total
                sql = "SELECT count(*) as total,course_name FROM ikcoder_appmain.students_lessonfinished group by course_name";
                DataTable dtData_FinishedLessonsTotal = _appLoader.ExecuteSQL(AppMain.Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, sql);

                //Build Sumary
                XmlNode sumaryNode = Util_XmlOperHelper.CreateNode(doc_Result, "sumary", "");
                rootNode.AppendChild(sumaryNode);
                Util_XmlOperHelper.SetAttribute(sumaryNode, "exp", totalExpValue.ToString());
                if (iTotalValue == 1)
                {
                    Util_XmlOperHelper.SetAttribute(sumaryNode, "over", "100");
                }
                else
                {
                    double dOver = (1.00 - (double)((double)iPosition / (double)iTotalValue)) * 100;
                    Util_XmlOperHelper.SetAttribute(sumaryNode, "over", Math.Round(dOver, 2).ToString());
                }
                Util_XmlOperHelper.SetAttribute(sumaryNode, "finished", iFinishedLessons.ToString());

                //Build Achieved
                XmlNode achievedNode = Util_XmlOperHelper.CreateNode(doc_Result, "achieved", "");
                rootNode.AppendChild(achievedNode);
                foreach (string lesson_code in lstLessonsFinished_Code)
                {
                    DataRow[] achievedRows = dtData_Achieved.Select("lesson_code='" + lesson_code + "'");
                    foreach (DataRow achievedRow in achievedRows)
                    {
                        string archieved_title = string.Empty;
                        Data_dbDataHelper.GetColumnData(achievedRow, "title", out archieved_title);
                        string archieved_content = string.Empty;
                        Data_dbDataHelper.GetColumnData(achievedRow, "content", out archieved_content);
                        XmlNode newAchievedItem = Util_XmlOperHelper.CreateNode(doc_Result, "item", "");
                        Util_XmlOperHelper.SetAttribute(newAchievedItem, "title", archieved_title);
                        Util_XmlOperHelper.SetAttribute(newAchievedItem, "content", archieved_content);
                        achievedNode.AppendChild(newAchievedItem);
                    }
                }

                //Build STEML
                XmlNode abilityNode    = Util_XmlOperHelper.CreateNode(doc_Result, "ability", "");
                XmlNode lessonsLstNode = Util_XmlOperHelper.CreateNode(doc_Result, "lstlessons", "");
                abilityNode.AppendChild(lessonsLstNode);
                XmlNode steamNode = Util_XmlOperHelper.CreateNode(doc_Result, "steam", "");
                abilityNode.AppendChild(steamNode);
                Dictionary <char, int> steamMapForLessons = new Dictionary <char, int>();
                foreach (string lesson_code in lstLessonsFinished_Code)
                {
                    if (dtData_Basic != null && dtData_Basic.Rows.Count > 0)
                    {
                        DataRow[] finishedLessonRows = dtData_Basic.Select("lesson_code='" + lesson_code + "'");
                        if (finishedLessonRows.Length > 0)
                        {
                            XmlNode finishedLessonRowsItem = Util_XmlOperHelper.CreateNode(doc_Result, "item", "");
                            string  lesson_title           = string.Empty;
                            string  lesson_steam           = string.Empty;
                            Data_dbDataHelper.GetColumnData(finishedLessonRows[0], "lesson_title", out lesson_title);
                            Data_dbDataHelper.GetColumnData(finishedLessonRows[0], "steam", out lesson_steam);
                            Util_XmlOperHelper.SetAttribute(finishedLessonRowsItem, "lesson_title", lesson_title);
                            lessonsLstNode.AppendChild(finishedLessonRowsItem);
                            char[] steam_chars = lesson_steam.ToCharArray();
                            foreach (char steam_char in steam_chars)
                            {
                                if (steamMapForLessons.ContainsKey(steam_char))
                                {
                                    steamMapForLessons[steam_char] = steamMapForLessons[steam_char] + 1;
                                }
                                else
                                {
                                    steamMapForLessons.Add(steam_char, 1);
                                }
                            }
                        }
                    }
                }
                foreach (char steam_char in steamMapForLessons.Keys)
                {
                    XmlNode newSteamNode = Util_XmlOperHelper.CreateNode(doc_Result, steam_char.ToString(), (steamMapForLessons[steam_char] * 100).ToString());
                    steamNode.AppendChild(newSteamNode);
                }
                rootNode.AppendChild(abilityNode);

                //Build Course Finsished Map
                XmlNode courseFinishedMapNode = Util_XmlOperHelper.CreateNode(doc_Result, "coursefinished", "");
                rootNode.AppendChild(courseFinishedMapNode);
                Dictionary <string, CourseMainInfoItem> totalfinished_courses = new Dictionary <string, CourseMainInfoItem>();
                foreach (DataRow courseRow in dtData_CourseMain.Rows)
                {
                    XmlNode newItemNode = Util_XmlOperHelper.CreateNode(doc_Result, "item", "");
                    courseFinishedMapNode.AppendChild(newItemNode);
                    string course_name = string.Empty;
                    Data_dbDataHelper.GetColumnData(courseRow, "name", out course_name);
                    Util_XmlOperHelper.SetAttribute(newItemNode, "name", course_name);
                    string course_title = string.Empty;
                    Data_dbDataHelper.GetColumnData(courseRow, "title", out course_title);
                    Util_XmlOperHelper.SetAttribute(newItemNode, "title", course_title);
                    DataRow[] rows_finishedLesson    = dtData_FinishedLesson.Select("course_name='" + course_name + "'");
                    string    lessonFinished_Total   = string.Empty;
                    int       i_lessonFinished_Total = 0;
                    if (rows_finishedLesson.Length > 0)
                    {
                        Data_dbDataHelper.GetColumnData(rows_finishedLesson[0], "total", out lessonFinished_Total);
                        int.TryParse(lessonFinished_Total, out i_lessonFinished_Total);
                        Util_XmlOperHelper.SetAttribute(newItemNode, "count_finished", lessonFinished_Total);
                    }
                    else
                    {
                        Util_XmlOperHelper.SetAttribute(newItemNode, "count_finished", "0");
                    }
                    DataRow[] rows_total      = dtData_LessonsTotal.Select("course_name='" + course_name + "'");
                    string    lessons_Total   = string.Empty;
                    int       i_lessons_Total = 1;
                    if (rows_total.Length > 0)
                    {
                        Data_dbDataHelper.GetColumnData(rows_total[0], "total", out lessons_Total);
                        int.TryParse(lessons_Total, out i_lessons_Total);
                        Util_XmlOperHelper.SetAttribute(newItemNode, "count_total", lessons_Total);
                    }
                    else
                    {
                        Util_XmlOperHelper.SetAttribute(newItemNode, "count_total", "1");
                    }
                    Util_XmlOperHelper.SetAttribute(newItemNode, "rate", ((i_lessonFinished_Total / i_lessons_Total) * 100).ToString());
                }


                //Build Time Line
                XmlNode timelineNode = Util_XmlOperHelper.CreateNode(doc_Result, "timeline", "");
                rootNode.AppendChild(timelineNode);
                if (dtData_LearningStatus != null && dtData_LearningStatus.Rows.Count > 0)
                {
                    DataRow[] start_rows = dtData_LearningStatus.Select("actions='" + Global.LearningActionsMap.LessonAction_StartLearning + "'");

                    foreach (DataRow start_row in start_rows)
                    {
                        string   str_start_rdt = string.Empty;
                        DateTime dt_start_rdt  = new DateTime();
                        Data_dbDataHelper.GetColumnData(start_row, "rfultime", out str_start_rdt);
                        DateTime.TryParse(str_start_rdt, out dt_start_rdt);
                        int    i_times  = Data_dbDataHelper.GetColumnIntData(start_row, "times");
                        string str_code = string.Empty;
                        Data_dbDataHelper.GetColumnData(start_row, "code", out str_code);
                        DataRow[] end_rows = dtData_LearningStatus.Select("actions='" + Global.LearningActionsMap.LessonAction_EndLearning + "' and code='" + str_code + "'");
                        TimeSpan  timeSpan = new TimeSpan();
                        bool      isEnded  = false;
                        string    end_dt   = string.Empty;
                        if (end_rows.Length > 0)
                        {
                            string str_end_rdt = string.Empty;
                            Data_dbDataHelper.GetColumnData(end_rows[0], "rfultime", out str_end_rdt);
                            DateTime dt_end_rdt = new DateTime();
                            DateTime.TryParse(str_end_rdt, out dt_end_rdt);
                            if (dt_end_rdt.Year == dt_start_rdt.Year && dt_end_rdt.Month == dt_start_rdt.Month && dt_end_rdt.Day == dt_start_rdt.Day)
                            {
                                isEnded  = true;
                                timeSpan = dt_end_rdt - dt_start_rdt;
                                end_dt   = dt_end_rdt.Year + "-" + dt_end_rdt.Month + "-" + dt_end_rdt.Day;
                            }
                        }
                        XmlNode timeItemNode = Util_XmlOperHelper.CreateNode(doc_Result, "item", "");
                        Util_XmlOperHelper.SetAttribute(timeItemNode, "hours", timeSpan.Hours.ToString());
                        Util_XmlOperHelper.SetAttribute(timeItemNode, "minutes", timeSpan.Minutes.ToString());
                        Util_XmlOperHelper.SetAttribute(timeItemNode, "dt", end_dt != string.Empty ? end_dt : DateTime.Now.ToString("yyyy-MM-dd"));
                        timelineNode.AppendChild(timeItemNode);
                    }
                }

                return(Content(doc_Result.OuterXml));
            }
            catch (Exception err)
            {
                return(Content(err.Message + "|" + err.StackTrace));
            }
        }
 public ContentResult Action(string course_name)
 {
     try
     {
         string uname = GetAccountInfoFromBasicController("name");
         Dictionary <string, string> paramsForBasic = new Dictionary <string, string>();
         paramsForBasic.Add("@course_name", course_name);
         List <string> lstCourses              = new List <string>();
         DataTable     dtData_lesson           = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_course_basic, paramsForBasic);
         Dictionary <string, string> paramsmap = new Dictionary <string, string>();
         paramsmap.Add("@uid", uname);
         DataTable dtData_finished = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_lessonfinished, paramsmap);
         paramsmap.Clear();
         paramsmap.Add("@uid", uname);
         DataTable   dtData_Learning = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_learninrecord, paramsmap);
         XmlDocument returnDoc       = new XmlDocument();
         returnDoc.LoadXml("<root></root>");
         foreach (DataRow row in dtData_lesson.Rows)
         {
             XmlNode itemNode = Util_XmlOperHelper.CreateNode(returnDoc, "item", "");
             returnDoc.SelectSingleNode("/root").AppendChild(itemNode);
             string lesson_title = string.Empty;
             string lesson_code  = string.Empty;
             string lesson_steam = string.Empty;
             string lesson_udba  = string.Empty;
             string lesson_steps = string.Empty;
             string lesson_order = string.Empty;
             Data_dbDataHelper.GetColumnData(row, "lesson_title", out lesson_title);
             Data_dbDataHelper.GetColumnData(row, "lesson_code", out lesson_code);
             Data_dbDataHelper.GetColumnData(row, "steam", out lesson_steam);
             Data_dbDataHelper.GetColumnData(row, "udba", out lesson_udba);
             Data_dbDataHelper.GetColumnData(row, "totalsteps", out lesson_steps);
             Data_dbDataHelper.GetColumnData(row, "lorder", out lesson_order);
             Util_XmlOperHelper.SetAttribute(itemNode, "lesson_title", lesson_title);
             Util_XmlOperHelper.SetAttribute(itemNode, "lesson_code", lesson_code);
             Util_XmlOperHelper.SetAttribute(itemNode, "steam", lesson_steam);
             Util_XmlOperHelper.SetAttribute(itemNode, "udba", lesson_udba);
             Util_XmlOperHelper.SetAttribute(itemNode, "totalsteps", lesson_steps);
             Util_XmlOperHelper.SetAttribute(itemNode, "order", lesson_order);
             Util_XmlOperHelper.SetAttribute(itemNode, "status", "0");
             if (dtData_Learning != null && dtData_Learning.Rows.Count > 0)
             {
                 DataRow[] learningRows = dtData_Learning.Select("code='" + lesson_code + "' and actions='" + Global.LearningActionsMap.LessonAction_StartLearning + "'");
                 if (learningRows.Length > 0)
                 {
                     Util_XmlOperHelper.SetAttribute(itemNode, "status", "1");
                 }
             }
             if (dtData_finished != null && dtData_finished.Rows.Count > 0)
             {
                 DataRow[] finishedRows = dtData_finished.Select("lesson_code='" + lesson_code + "'");
                 if (finishedRows.Length > 0)
                 {
                     Util_XmlOperHelper.SetAttribute(itemNode, "status", "2");
                 }
             }
         }
         return(Content(returnDoc.OuterXml));
     }
     catch
     {
         return(Content(MessageHelper.ExecuteFalse()));
     }
 }