예제 #1
0
        public static string CreatePara(KeyValuePair <string, string>[] funcPara, string exAttr)
        {
            string ret = string.Format("<{0} />", TagName);

            try
            {
                //Add UserInfo -----------------------------------------------------------
                CSession session = new CSession();
                List <KeyValuePair <string, string> > list    = new List <KeyValuePair <string, string> >();
                KeyValuePair <string, string>[]       sysPara = new KeyValuePair <string, string>[]
                {
                    new KeyValuePair <string, string>("UserID", session.UserID.ToString()),
                    new KeyValuePair <string, string>("Session", session.Session),
                };

                list.AddRange(sysPara);
                list.AddRange(funcPara);
                sysPara = list.ToArray <KeyValuePair <string, string> >();
                //-------------------------------------------------------------------------

                XmlNode node = CXml.CreateNode(TagName, sysPara);
                ret = node.OuterXml;
                if (exAttr != "")
                {
                    ret = ret.Replace("/>", exAttr + "/>");
                }
            }
            catch
            {
            }
            return(ret);
        }
예제 #2
0
        private static string AddMetaToInputValue(string pInputValue)
        {
            CSession    session = new CSession();
            XmlDocument doc     = new XmlDocument();

            try
            {
                doc.LoadXml(pInputValue);
                XmlElement rootNode = doc.DocumentElement; // Lay InputValue node

                //Tao 2 attribute userId va Session
                if (!rootNode.HasAttribute("UserID"))
                {
                    XmlAttribute userAttr = doc.CreateAttribute("UserID");
                    userAttr.Value = session.UserID.ToString();
                    rootNode.Attributes.Append(userAttr);
                }
                if (!rootNode.HasAttribute("Session"))
                {
                    XmlAttribute sessionAttr = doc.CreateAttribute("Session");
                    sessionAttr.Value = session.Session;
                    rootNode.Attributes.Append(sessionAttr);
                }
                //them vao InputValue, neu InputValue co attribute UserID hoac Session se bi loi.
            }
            catch (XmlException)
            {
                //invalid input
            }
            return(doc.OuterXml);
        }
예제 #3
0
        public static void RegisterServerConfig(Page page)
        {
            CSession session      = new CSession();
            CJson    serverConfig = new CJson(
                new CPara("Culture", session.Culture),
                new CPara("DateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                new CPara("Date", DateTime.Now.ToString("yyyy-MM-dd")),
                new CPara("DateFrom", DateTime.Now.AddMonths(FromDate_ByMonth).ToString("yyyy-MM-dd")),
                new CPara("ServiceData", ServiceUrl),
                new CPara("ClientKey", ClientKey),
                new CPara("VirtualDirectory", VirtualDirectory),
                new CPara("HostName", HostName)
                );

            StringBuilder script = new StringBuilder();

            script.AppendFormat("var FWS_SERVER_CONFIG = {0}; \n", serverConfig.ToJson());
            page.ClientScript.RegisterClientScriptBlock(page.GetType(), "FWS.Server.Config", script.ToString(), true);
        }