Esempio n. 1
0
        public string Action_Get_DialogContent(string symbolMessage, AppLoader existedLoader)
        {
            Dictionary <string, string> activeParams = new Dictionary <string, string>();

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

            if (activeDataTable == null || activeDataTable.Rows.Count == 0)
            {
                StringBuilder strReturnDoc = new StringBuilder();
                strReturnDoc.Append("<root type='passive'>");
                strReturnDoc.Append("<action>" + Global.ActionsMap.Action_Get_RelationsList + "</action>");
                strReturnDoc.Append("</root>");
                return(strReturnDoc.ToString());
            }
            else
            {
                StringBuilder resultStr        = new StringBuilder();
                string        base64MsgContent = string.Empty;
                Data_dbDataHelper.GetArrByteColumnDataToString(activeDataTable.Rows[0], "content", out base64MsgContent);
                string MsgContent = Util_Common.Decoder_Base64(base64MsgContent);
                string dialogID   = string.Empty;
                Data_dbDataHelper.GetArrByteColumnDataToString(activeDataTable.Rows[0], "id", out dialogID);
                resultStr.Append("<did>");
                resultStr.Append(dialogID);
                resultStr.Append("</did>");
                resultStr.Append(MsgContent);
                return(resultStr.ToString());
            }
        }
Esempio n. 2
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>");
            }
        }
 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(""));
     }
 }
Esempio n. 4
0
 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()));
     }
 }
Esempio n. 5
0
        /*
         * 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());
        }
Esempio n. 6
0
        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 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()));
     }
 }