public ContentResult actionResult(string withpath = "1") { try { string token = _appLoader.get_ClientToken(Request, "student_token"); Global.ItemAccountStudents activeItem = Global.LoginServices.Pull(token); Dictionary <string, string> paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@uid", activeItem.name); DataTable dt = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); if (dt != null && dt.Rows.Count > 0) { string header = string.Empty; Data_dbDataHelper.GetColumnData(dt.Rows[0], "header", out header); if (withpath == "1") { string filePath = iKCoderComps.FileStore.GetImageStore(activeItem.id); return(Content(MessageHelper.ExecuteSucessful("800", filePath + "\\" + header))); } else { return(Content(MessageHelper.ExecuteSucessful("800", header))); } } else { return(Content(MessageHelper.ExecuteFalse())); } } catch (Basic_Exceptions err) { return(Content(MessageHelper.ExecuteFalse())); } }
public ContentResult actionResult() { try { string token = _appLoader.get_ClientToken(Request, "student_token"); Global.ItemAccountStudents activeItem = Global.LoginServices.Pull(token); Dictionary <string, string> paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@uid", activeItem.name); DataTable dtData = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); if (dtData != null && dtData.Rows.Count > 0) { string nickName = string.Empty; string birthday = string.Empty; string country = string.Empty; string state = string.Empty; string city = string.Empty; string realname = string.Empty; Dictionary <string, string> resturnMap = new Dictionary <string, string>(); Data_dbDataHelper.GetColumnData(dtData.Rows[0], "nickname", out nickName); Data_dbDataHelper.GetColumnData(dtData.Rows[0], "birthday", out birthday); Data_dbDataHelper.GetColumnData(dtData.Rows[0], "country", out country); Data_dbDataHelper.GetColumnData(dtData.Rows[0], "state", out state); Data_dbDataHelper.GetColumnData(dtData.Rows[0], "city", out city); Data_dbDataHelper.GetColumnData(dtData.Rows[0], "realname", out realname); if (!string.IsNullOrEmpty(nickName)) { resturnMap.Add("nickname", nickName); } if (!string.IsNullOrEmpty(birthday)) { resturnMap.Add("birthday", birthday); } if (!string.IsNullOrEmpty(country)) { resturnMap.Add("country", country); } if (!string.IsNullOrEmpty(state)) { resturnMap.Add("state", state); } if (!string.IsNullOrEmpty(city)) { resturnMap.Add("city", city); } if (!string.IsNullOrEmpty(realname)) { resturnMap.Add("realname", city); } return(Content(MessageHelper.ExecuteSucessfulDoc(resturnMap))); } else { return(Content(MessageHelper.ExecuteFalse())); } } catch (Basic_Exceptions err) { return(Content(MessageHelper.ExecuteFalse())); } }
public ContentResult Action() { string data = _appLoader.get_PostData(HttpContext.Request); Dictionary <string, string> paramsMap = new Dictionary <string, string>(); DataTable dtData = _appLoader.ExecuteSelect(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_store_demo_raw); foreach (DataRow dr in dtData.Rows) { string rdt = string.Empty; Data_dbDataHelper.GetColumnData(dr, "rdt", out rdt); DateTime tmpRDT = DateTime.Parse(rdt); if ((DateTime.Now - tmpRDT).Days >= 7) { string id = string.Empty; Data_dbDataHelper.GetColumnData(dr, "id", out id); paramsMap.Clear(); paramsMap.Add("id", id); _appLoader.ExecuteDeleteWithID(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_store_demo_raw, paramsMap); } } paramsMap.Clear(); paramsMap.Add("rdt", DateTime.Now.ToString("yyyy-MM-dd")); string symbol = Guid.NewGuid().ToString(); paramsMap.Add("symbol", symbol); paramsMap.Add("content", data); _appLoader.ExecuteInsert(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_store_demo_raw, paramsMap); return(Content(MessageHelper.ExecuteSucessful("symbol", symbol))); }
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>"); } }
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]))); } }
public ContentResult actionResult(string uname) { try { Dictionary <string, string> activeParams = new Dictionary <string, string>(); activeParams.Add("name", uname); DataTable dtUser = new DataTable(); dtUser = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_account_students, activeParams); string uid = string.Empty; Data_dbDataHelper.GetColumnData(dtUser.Rows[0], "id", out uid); Dictionary <string, string> paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@uid", uname); DataTable dt = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); if (dt != null && dt.Rows.Count > 0) { string header = string.Empty; Data_dbDataHelper.GetColumnData(dt.Rows[0], "header", out header); if (string.IsNullOrEmpty(header)) { return(Content("")); } string filePath = iKCoderComps.FileStore.GetImageStore(_appLoader.GetAPICurrentPath(), uid); try { FileStream fileStream = new FileStream(filePath + header, FileMode.Open); BinaryReader binaryReader = new BinaryReader(fileStream); byte[] dataBuffer = binaryReader.ReadBytes((int)fileStream.Length); string strB64 = Util_Common.Encoder_Base64(dataBuffer); binaryReader.Close(); fileStream.Close(); string[] filenameAttrs = header.Split("."); string entendType = filenameAttrs[filenameAttrs.Length - 1]; string result = "data:image/"; if (entendType == "icon") { result = result + "x-icon;base64,"; } else { result = result + entendType + ";base64,"; } return(Content(result + strB64)); } catch { return(Content("")); } } else { return(Content("")); } } catch (Basic_Exceptions err) { return(Content("")); } }
public ContentResult actionResult(string name, string pwd, string checkcode) { try { Dictionary <string, string> activeParams = new Dictionary <string, string>(); activeParams.Add("name", name); if (_appLoader.VerifyNotEmpty(activeParams)) { string checkcodefromsession = string.Empty; if (HttpContext.Session.Keys.Contains("checkcode")) { checkcodefromsession = HttpContext.Session.GetString("checkcode"); } else { return(Content(MessageHelper.ExecuteFalse("400", "null checkcode"))); } if (checkcodefromsession != checkcode) { return(Content(MessageHelper.ExecuteFalse("400", "wrong checkcode"))); } DataTable dtUser = new DataTable(); dtUser = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_account_students, activeParams); if (dtUser != null && dtUser.Rows.Count == 1) { string uid = string.Empty; string password = string.Empty; Data_dbDataHelper.GetColumnData(dtUser.Rows[0], "id", out uid); Data_dbDataHelper.GetColumnData(dtUser.Rows[0], "password", out password); if (password == pwd) { Global.ItemAccountStudents newItem = Global.ItemAccountStudents.CreateNewItem(uid, name, pwd, ""); Global.LoginServices.Push(newItem); Response.Cookies.Append("student_token", newItem.token); return(Content(MessageHelper.ExecuteSucessful("TOKEN", newItem.token))); } else { return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Login_InvalidatedPwd], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Login_InvalidatedPwd]))); } } else { return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Login_NoUser], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Login_NoUser]))); } } else { return(Content(MessageHelper.ExecuteSucessful())); } } catch (Basic_Exceptions err) { return(Content(MessageHelper.ExecuteFalse())); } }
public ContentResult actionResult() { try { var files = Request.Form.Files; long fileSize = files.Sum(f => f.Length); List <string> filePathResultList = new List <string>(); foreach (var file in files) { string token = _appLoader.get_ClientToken(Request, "student_token"); Global.ItemAccountStudents activeItem = Global.LoginServices.Pull(token); string fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.ToString().Trim(); string filePath = iKCoderComps.FileStore.GetImageStore(_appLoader.GetAPICurrentPath(), activeItem.id); iKCoderComps.FileStore.VerifyUserStorItem(_appLoader.GetAPICurrentPath(), activeItem.id); fileName = Guid.NewGuid() + "." + fileName.Split('.')[1]; fileName = fileName.Replace("\"", ""); Dictionary <string, string> paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@uid", activeItem.name); DataTable dtData = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); if (dtData != null && dtData.Rows.Count > 0) { string header = string.Empty; Data_dbDataHelper.GetColumnData(dtData.Rows[0], "header", out header); fileName = header; string id = string.Empty; Data_dbDataHelper.GetColumnData(dtData.Rows[0], "id", out id); paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@id", id); paramsMap_for_profle.Add("@header", fileName); if (_appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle)) { string fileFullName = filePath + fileName; using (FileStream fs = System.IO.File.Create(fileFullName)) { file.CopyTo(fs); fs.Flush(); } } else { return(Content(MessageHelper.ExecuteFalse())); } } else { return(Content(MessageHelper.ExecuteFalse())); } } return(Content(MessageHelper.ExecuteSucessful())); } catch (Basic_Exceptions err) { return(Content(MessageHelper.ExecuteFalse())); } }
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 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]))); } }
public ContentResult actionResult() { try { string data = _appLoader.get_PostData(HttpContext.Request, "data"); string token = _appLoader.get_ClientToken(Request, "student_token"); if (string.IsNullOrEmpty(data)) { return(Content(MessageHelper.ExecuteFalse())); } byte[] dataBuffer = Util_Common.Decoder_Base64ToBytes(data); Global.ItemAccountStudents activeItem = Global.LoginServices.Pull(token); FileStore.VerifyUserStorItem(_appLoader.GetAPICurrentPath(), activeItem.id); Dictionary <string, string> paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@uid", activeItem.name); DataTable dt = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); if (dt != null && dt.Rows.Count > 0) { string header = string.Empty; Data_dbDataHelper.GetColumnData(dt.Rows[0], "header", out header); if (string.IsNullOrEmpty(header)) { return(Content(MessageHelper.ExecuteFalse())); } string filePath = iKCoderComps.FileStore.GetImageStore(_appLoader.GetAPICurrentPath(), activeItem.id); try { FileStream fileStream = new FileStream(filePath + header, FileMode.Create); BinaryWriter binaryWriter = new BinaryWriter(fileStream); binaryWriter.Write(dataBuffer); binaryWriter.Flush(); binaryWriter.Close(); fileStream.Close(); return(Content(MessageHelper.ExecuteSucessful())); } catch { return(Content(MessageHelper.ExecuteFalse())); } } else { return(Content(MessageHelper.ExecuteFalse())); } } catch (Basic_Exceptions err) { return(Content(MessageHelper.ExecuteFalse())); } }
public ContentResult Action(string lesson_code, string course_name) { try { if (string.IsNullOrEmpty(lesson_code)) { return(Content(MessageHelper.ExecuteFalse())); } Dictionary <string, string> paramsmap = new Dictionary <string, string>(); string uname = GetAccountInfoFromBasicController("name"); paramsmap.Add("@uid", uname); paramsmap.Add("@lesson_code", lesson_code); DataTable dtData = _appLoader.ExecuteSelectWithMixedConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_lessonfinished, paramsmap); if (dtData != null && dtData.Rows.Count == 1) { string finished_id = string.Empty; Data_dbDataHelper.GetColumnData(dtData.Rows[0], "id", out finished_id); paramsmap.Clear(); paramsmap.Add("@id", finished_id); paramsmap.Add("@rdt", DateTime.Now.ToString("yyyy-MM-dd")); _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_lessonfinished, paramsmap); } else { paramsmap.Add("@rdt", DateTime.Now.ToString("yyyy-MM-dd")); paramsmap.Add("@course_name", course_name); _appLoader.ExecuteInsert(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_lessonfinished, paramsmap); paramsmap.Clear(); paramsmap.Add("@lesson_code", lesson_code); DataTable dt_lessonExp = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_exp_defined, paramsmap); DataRow activeRow_LessonExp = null; Data_dbDataHelper.GetActiveRow(dt_lessonExp, 0, out activeRow_LessonExp); int iLessonExp = Data_dbDataHelper.GetColumnIntData(activeRow_LessonExp, "exp"); paramsmap.Clear(); paramsmap.Add("@uid", uname); paramsmap.Add("@exp", iLessonExp.ToString()); paramsmap.Add("@rdate", DateTime.Now.ToString()); paramsmap.Add("@symbol", lesson_code); _appLoader.ExecuteInsert(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_exp, 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 ContentResult actionResult(string sex, string nickname, string birthday, string state, string city, string realname, string country = "China") { Global.ItemAccountStudents activeItem = _appLoader.get_SessionObject(HttpContext.Session, "student_item") as Global.ItemAccountStudents; Dictionary <string, string> paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@uid", activeItem.name); DataTable dtData = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); string id = string.Empty; Data_dbDataHelper.GetColumnData(dtData.Rows[0], "id", out id); paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@id", id); if (!string.IsNullOrEmpty(nickname)) { paramsMap_for_profle.Add("@nickname", nickname); } if (!string.IsNullOrEmpty(birthday)) { paramsMap_for_profle.Add("@birthday", birthday); } if (!string.IsNullOrEmpty(country)) { paramsMap_for_profle.Add("@country", country); } if (!string.IsNullOrEmpty(state)) { paramsMap_for_profle.Add("@state", state); } if (!string.IsNullOrEmpty(city)) { paramsMap_for_profle.Add("@city", city); } if (!string.IsNullOrEmpty(realname)) { paramsMap_for_profle.Add("@realname", realname); } if (_appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle)) { return(Content(MessageHelper.ExecuteSucessful())); } else { return(Content(MessageHelper.ExecuteFalse())); } }
/* * public string Action_Set_RemoveFromChatGroup(string dialogSymbol, string owner, AppLoader existedLoader) * { * Dictionary<string, string> activeParams = new Dictionary<string, string>(); * activeParams.Add("symbol", dialogSymbol); * DataTable dtMessageIndex = existedLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_messagesindex_students, activeParams); * Dictionary<string, string> existedIndexLst = new Dictionary<string, string>(); * foreach (DataRow dr in dtMessageIndex.Rows) * { * string existedUID = string.Empty; * string existedID = string.Empty; * Data_dbDataHelper.GetColumnData(dr, "uid", out existedUID); * * if (!existedIndexLst.Contains(existedUID)) * existedIndexLst.Add(existedUID); * } * if(existedIndexLst.Contains(owner)) * { * * } * } */ public string Action_Set_NewDialog(string token, List <string> lstOwners, AppLoader existedLoader) { string symbol_dialog = Guid.NewGuid().ToString(); Dictionary <string, string> activeParams = new Dictionary <string, string>(); activeParams.Add("symbol", symbol_dialog); DataTable dtMessageIndex = existedLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_messagesindex_students, activeParams); List <string> existedIndexLst = new List <string>(); foreach (DataRow dr in dtMessageIndex.Rows) { string existedUID = string.Empty; Data_dbDataHelper.GetColumnData(dr, "uid", out existedUID); if (!existedIndexLst.Contains(existedUID)) { existedIndexLst.Add(existedUID); } } foreach (string owner in lstOwners) { if (!existedIndexLst.Contains(owner)) { if (activeParams.ContainsKey("uid")) { activeParams.Remove("uid"); } activeParams.Add("uid", owner); existedLoader.ExecuteInsert(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_messagesindex_students, activeParams); } } activeParams.Clear(); activeParams.Add("symbol", symbol_dialog); string newMsgContent = "<msg></msg>"; string base64Content = Util_Common.Encoder_Base64(newMsgContent); activeParams.Add("content", base64Content); existedLoader.ExecuteInsert(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_messages_students, activeParams); StringBuilder strReturnDoc = new StringBuilder(); strReturnDoc.Append("<root type='passive'>"); strReturnDoc.Append("<action>" + Global.ActionsMap.Action_Get_DialogList + "</action>"); strReturnDoc.Append("</root>"); return(strReturnDoc.ToString()); }
public ContentResult actionResult(string name, string pwd) { try { Dictionary <string, string> activeParams = new Dictionary <string, string>(); activeParams.Add("name", name); if (_appLoader.VerifyNotEmpty(activeParams)) { DataTable dtUser = new DataTable(); dtUser = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_account_students, activeParams); if (dtUser != null && dtUser.Rows.Count == 1) { string uid = string.Empty; string password = string.Empty; Data_dbDataHelper.GetColumnData(dtUser.Rows[0], "id", out uid); Data_dbDataHelper.GetColumnData(dtUser.Rows[0], "password", out password); if (password == pwd) { Global.ItemAccountStudents newItem = Global.ItemAccountStudents.CreateNewItem(uid, name, pwd, ""); Global.LoginServices.Push(newItem); Response.Cookies.Append("student_token", newItem.token); return(Content(MessageHelper.ExecuteSucessful())); } else { return(Content(MessageHelper.ExecuteFalse())); } } else { return(Content(MessageHelper.ExecuteFalse())); } } else { return(Content(MessageHelper.ExecuteFalse())); } } catch (Basic_Exceptions err) { return(Content(MessageHelper.ExecuteFalse())); } }
public ContentResult Action() { try { string accoutInfo = RequestForString("Account_Students_GetCurrentAccountInfo", true); XmlDocument accountInfoDoc = new XmlDocument(); accountInfoDoc.LoadXml(accoutInfo); XmlNode rootNode = accountInfoDoc.SelectSingleNode("/root"); if (rootNode != null) { string id = Util_XmlOperHelper.GetAttrValue(rootNode, "id"); Dictionary <string, string> lstParams = new Dictionary <string, string>(); lstParams.Add("uid", id); DataTable dtExp = _appLoader.ExecuteSelectWithMixedConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_students_exp, lstParams); if (dtExp != null && dtExp.Rows.Count > 0) { DataRow currentRow = null; Data_dbDataHelper.GetActiveRow(dtExp, 0, out currentRow); string strExp = string.Empty; Data_dbDataHelper.GetColumnData(currentRow, "exp", out strExp); int currentExp = 0; int.TryParse(strExp, out currentExp); DataTable dtData = _appLoader.ExecuteSelect(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_titles_defined); //foreach(DataRow ) return(Content(Data_dbDataHelper.ActionConvertDTtoXMLString(dtData))); } else { return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Fetch_Error], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Fetch_Error]))); } } else { return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Login_Needed], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Login_Needed]))); } } catch { return(Content(MessageHelper.ExecuteFalse(Global.MsgMap.MsgCodeMap[Global.MsgKeyMap.MsgKey_Fetch_Error], Global.MsgMap.MsgContentMap[Global.MsgKeyMap.MsgKey_Fetch_Error]))); } }
public ContentResult Action(string id) { Dictionary <string, string> paramsmap = new Dictionary <string, string>(); string uname = GetAccountInfoFromBasicController("name"); paramsmap.Add("@id", id); DataTable dtData = _appLoader.ExecuteSelectWithMixedConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_appstudio_store, paramsmap); if (dtData != null && dtData.Rows.Count == 1) { string base64StrContentDoc = string.Empty; string StrContentDoc = string.Empty; Data_dbDataHelper.GetColumnData(dtData.Rows[0], "contentdoc", out base64StrContentDoc); StrContentDoc = Util_Common.Decoder_Base64(base64StrContentDoc); return(Content(StrContentDoc)); } else { return(Content(MessageHelper.ExecuteFalse())); } }
public string Action_Set_AcceptFriend(string id, AppLoader existedLoader) { Dictionary <string, string> paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@id", id); DataTable dtData = existedLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_relations_students, paramsMap_for_profle); if (dtData != null && dtData.Rows.Count == 1) { paramsMap_for_profle.Add("@isacc", "1"); if (existedLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_relations_students, paramsMap_for_profle)) { string puname = string.Empty; Data_dbDataHelper.GetColumnData(dtData.Rows[0], "puname", out puname); if (_accountTokenMap.ContainsKey(puname)) { string owner_token = _accountTokenMap[puname]; WebSocket owner_socket = null; if (_sockets.ContainsKey(owner_token)) { owner_socket = _sockets[owner_token]; StringBuilder message = new StringBuilder(); message.Append("<root type='passive'>"); message.Append("<action>" + Global.ActionsMap.Action_Get_RelationsList + "</action>"); message.Append("</root>"); SendStringAsync(owner_socket, BuildReturnDoc(message.ToString(), Global.ActionsMap.Action_Get_RelationsList, false)); } } return(MessageHelper.ExecuteSucessful()); } else { return(MessageHelper.ExecuteFalse()); } } else { return(MessageHelper.ExecuteFalse()); } }
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()); } }
public ContentResult action(string projectname) { try { string postData = _appLoader.get_PostData(HttpContext.Request); string base64PostData = Util_Common.Encoder_Base64(postData); Dictionary <string, string> paramsmap = new Dictionary <string, string>(); string uname = GetAccountInfoFromBasicController("name"); paramsmap.Add("@uid", uname); paramsmap.Add("@pname", projectname); DataTable dtData = _appLoader.ExecuteSelectWithMixedConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_appstudio_store, paramsmap); bool isUpdated = false; if (dtData != null && dtData.Rows.Count == 1) { isUpdated = true; string id = string.Empty; Data_dbDataHelper.GetColumnData(dtData.Rows[0], "id", out id); paramsmap.Add("@id", id); } paramsmap.Add("@contentdoc", base64PostData); paramsmap.Add("@imdt", DateTime.Now.ToString()); if (isUpdated) { _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_appstudio_store, paramsmap); } else { _appLoader.ExecuteInsert(Global.GlobalDefines.DB_KEY_IKCODER_APPMAIN, Global.MapStoreProcedures.ikcoder_appmain.spa_operation_appstudio_store, paramsmap); } return(Content(MessageHelper.ExecuteSucessful())); } catch { return(Content(MessageHelper.ExecuteFalse())); } }
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 IActionResult actionResult(string uname) { try { Dictionary <string, string> activeParams = new Dictionary <string, string>(); activeParams.Add("name", uname); DataTable dtUser = new DataTable(); dtUser = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_account_students, activeParams); string uid = string.Empty; Data_dbDataHelper.GetColumnData(dtUser.Rows[0], "id", out uid); Dictionary <string, string> paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@uid", uname); DataTable dt = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); if (dt != null && dt.Rows.Count > 0) { string header = string.Empty; Data_dbDataHelper.GetColumnData(dt.Rows[0], "header", out header); if (string.IsNullOrEmpty(header)) { return(Content("")); } string filePath = iKCoderComps.FileStore.GetImageStore(_appLoader.GetAPICurrentPath(), uid); try { var contentTypDict = new Dictionary <string, string> { { "jpg", "image/jpeg" }, { "jpeg", "image/jpeg" }, { "jpe", "image/jpeg" }, { "png", "image/png" }, { "gif", "image/gif" }, { "ico", "image/x-ico" }, { "tif", "image/tiff" }, { "tiff", "image/tiff" }, { "fax", "image/fax" }, { "wbmp", "image//vnd.wap.wbmp" }, { "rp", "image/vnd.rn-realpix" } }; FileStream fileStream = new FileStream(filePath + header, FileMode.Open); BinaryReader binaryReader = new BinaryReader(fileStream); byte[] dataBuffer = binaryReader.ReadBytes((int)fileStream.Length); binaryReader.Close(); fileStream.Close(); string[] filenameAttrs = header.Split("."); string entendType = filenameAttrs[filenameAttrs.Length - 1]; return(new FileContentResult(dataBuffer, contentTypDict[entendType])); } catch { return(Content("")); } } else { return(Content("")); } } catch (Basic_Exceptions err) { return(Content("")); } }
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())); } }
public void Processor_CheckStatus(Object param) { class_Data_SqlSPEntry activeSP = Map_SPS["spa_operation_db_reg"]; while (true) { DataTable regTable = db_objectSqlHelper.ExecuteSelectSPForDT(activeSP, db_objectConnectionHelper, Program.key_db_ikcoder_store); foreach (DataRow activeDR in regTable.Rows) { string id = string.Empty; string dbkey = string.Empty; string dbserver = string.Empty; string dbuid = string.Empty; string dbpwd = string.Empty; string dbdatabase = string.Empty; string tindex = string.Empty; string storetable = string.Empty; string limitedrows = string.Empty; string rows = string.Empty; string online = string.Empty; Data_dbDataHelper.GetColumnData(activeDR, "id", out id); Data_dbDataHelper.GetColumnData(activeDR, "dbkey", out dbkey); Data_dbDataHelper.GetColumnData(activeDR, "dbserver", out dbserver); Data_dbDataHelper.GetColumnData(activeDR, "dbuid", out dbuid); Data_dbDataHelper.GetColumnData(activeDR, "dbpwd", out dbpwd); Data_dbDataHelper.GetColumnData(activeDR, "dbdatabase", out dbdatabase); Data_dbDataHelper.GetColumnData(activeDR, "storetable", out storetable); Data_dbDataHelper.GetColumnData(activeDR, "limitedrows", out limitedrows); Data_dbDataHelper.GetColumnData(activeDR, "rows", out rows); Data_dbDataHelper.GetColumnData(activeDR, "online", out online); if (db_objectConnectionHelper.Get_ExistedConnection(dbkey)) { db_objectConnectionHelper.Set_RemoveExistedConnection(dbkey); } ConsoleMessageItem CMI = new ConsoleMessageItem(); CMI.Message = "Try:@->Connect to server:" + dbserver; Program.obj_message.set_newMessage(CMI); if (db_objectConnectionHelper.Set_NewConnectionItem(dbkey, dbserver, dbuid, dbpwd, dbdatabase, enum_DatabaseType.MySql)) { CMI.Message = "Result:@->Faild to connect to;" + dbserver; Program.obj_message.set_newMessage(CMI); online = "0"; } else { CMI.Message = "Result:@->Connected to:" + dbserver; Program.obj_message.set_newMessage(CMI); online = "1"; string tmpSql = "select count(*) as rows from " + storetable; DataTable dtCount = null; Data_dbDataHelper.ActionExecuteSQLForDT(db_objectConnectionHelper.Get_ActiveConnection(dbkey), tmpSql, out dtCount); if (dtCount != null && dtCount.Rows.Count > 0) { string tmpRows = string.Empty; Data_dbDataHelper.GetColumnData(dtCount.Rows[0], "rows", out tmpRows); if (tmpRows != rows) { rows = tmpRows; } } activeSP.ModifyParameterValue("id", id); activeSP.ModifyParameterValue("rows", rows); activeSP.ModifyParameterValue("online", online); db_objectSqlHelper.ExecuteUpdateSP(activeSP, db_objectConnectionHelper, dbkey); CMI.Message = "Result:@->Update reg information:" + dbserver; Program.obj_message.set_newMessage(CMI); } } Thread.Sleep(1000 * 30); } }
public ContentResult actionResult(string sex = "", string nickname = "", string birthday = "", string state = "", string city = "", string realname = "", string country = "China", string school = "") { try { string token = _appLoader.get_ClientToken(Request, "student_token"); Global.ItemAccountStudents activeItem = Global.LoginServices.Pull(token); Dictionary <string, string> paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@uid", activeItem.name); DataTable dtData = _appLoader.ExecuteSelectWithConditionsReturnDT(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); string id = string.Empty; Data_dbDataHelper.GetColumnData(dtData.Rows[0], "id", out id); paramsMap_for_profle = new Dictionary <string, string>(); paramsMap_for_profle.Add("@id", id); if (!string.IsNullOrEmpty(nickname)) { paramsMap_for_profle.Add("@nickname", nickname); _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); paramsMap_for_profle.Remove("@nickname"); } if (!string.IsNullOrEmpty(birthday)) { paramsMap_for_profle.Add("@birthday", birthday); _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); paramsMap_for_profle.Remove("@birthday"); } if (!string.IsNullOrEmpty(country)) { paramsMap_for_profle.Add("@country", country); _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); paramsMap_for_profle.Remove("@country"); } if (!string.IsNullOrEmpty(state)) { paramsMap_for_profle.Add("@state", state); _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); paramsMap_for_profle.Remove("@state"); } if (!string.IsNullOrEmpty(city)) { paramsMap_for_profle.Add("@city", city); _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); paramsMap_for_profle.Remove("@city"); } if (!string.IsNullOrEmpty(sex)) { paramsMap_for_profle.Add("@sex", sex); _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); paramsMap_for_profle.Remove("@sex"); } if (!string.IsNullOrEmpty(realname)) { paramsMap_for_profle.Add("@realname", realname); _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); paramsMap_for_profle.Remove("@realname"); } if (!string.IsNullOrEmpty(school)) { paramsMap_for_profle.Add("@school", school); _appLoader.ExecuteUpdate(Global.GlobalDefines.DB_KEY_IKCODER_BASIC, Global.MapStoreProcedures.ikcoder_basic.spa_operation_profile_students, paramsMap_for_profle); paramsMap_for_profle.Remove("@school"); } return(Content(MessageHelper.ExecuteSucessful())); } catch { return(Content(MessageHelper.ExecuteFalse())); } }