Esempio n. 1
0
 public Account GetAuthenticatedAccount()
 {
     if (HttpContext.Current.Request["Authenticator"] != null && HttpContext.Current.Request["accountID"] != null)
     {
         SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current);
         string     actID      = ssoRequest.AccountID;
         if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID))
         {
             Security.SetAccountID(actID);
             return(RemoteHelper.GetAccount(actID, null));
         }
         else
         {
             return(null);
         }
     }
     else if (HttpContext.Current.Request["Authenticator"] == null)
     {
         SSORequest req = new SSORequest();
         req.Action = "authenticate";
         req.SiteID = SiteConfigs.GetConfig().SiteID;
         Authentication.CreateAppToken(req);
         Authentication.Post(req, SiteConfigs.GetConfig().PassportAuthPage);
         return(null);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 2
0
        public void AdvancedPathSplitting()
        {
            const string path = "PLC.Modules.<Default>.OPCua_Axis:opc_Axis.StatusX.Homing";

            string firstElement;
            var    restOfPath = RemoteHelper.RestOfPath(path, out firstElement);

            Assert.IsTrue(firstElement == "PLC");
            Assert.IsTrue(restOfPath == "Modules.<Default>.OPCua_Axis:opc_Axis.StatusX.Homing");

            restOfPath = RemoteHelper.RestOfPath(restOfPath, out firstElement);
            Assert.IsTrue(firstElement == "Modules");
            Assert.IsTrue(restOfPath == "<Default>.OPCua_Axis:opc_Axis.StatusX.Homing");

            restOfPath = RemoteHelper.RestOfPath(restOfPath, out firstElement);
            Assert.IsTrue(firstElement == "<Default>");
            Assert.IsTrue(restOfPath == "OPCua_Axis:opc_Axis.StatusX.Homing");

            restOfPath = RemoteHelper.RestOfPath(restOfPath, out firstElement);
            Assert.IsTrue(firstElement == "OPCua_Axis");
            Assert.IsTrue(restOfPath == "opc_Axis.StatusX.Homing");

            restOfPath = RemoteHelper.RestOfPath(restOfPath, out firstElement);
            Assert.IsTrue(firstElement == "opc_Axis");
            Assert.IsTrue(restOfPath == "StatusX.Homing");

            restOfPath = RemoteHelper.RestOfPath(restOfPath, out firstElement);
            Assert.IsTrue(firstElement == "StatusX");
            Assert.IsTrue(restOfPath == "Homing");

            restOfPath = RemoteHelper.RestOfPath(restOfPath, out firstElement);
            Assert.IsTrue(firstElement == "Homing");
            Assert.IsTrue(restOfPath == "");
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            {
                for (int i = 0; i < 5; i++)
                {
                    List <Program> programs = DBHelper.Query <Program>();
                    if (CacheManager.Contains("DBHelper"))
                    {
                        List <Program> programList = DBHelper.Query <Program>();
                        CacheManager.Add("DBHelper", programList);
                    }
                    List <Program> programResult = CacheManager.GetData <List <Program> >("DBHelper");

                    List <Program> result = CacheManager.Get <List <Program> >("DBHelper",
                                                                               () => DBHelper.Query <Program>(), 30);
                }
                for (int i = 0; i < 5; i++)
                {
                    List <Program> programs = FileHelper.Query <Program>();
                }
                for (int i = 0; i < 5; i++)
                {
                    List <Program> programs = RemoteHelper.Query <Program>();
                }
            }

            Console.ReadKey();
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the client-side data as a <see cref="JToken"/>
        /// </summary>
        /// <returns></returns>
        JToken CreateNodeJObject(Document document)
        {
            Contract.Requires <ArgumentNullException>(document != null);

            // serialize document state to data field
            using (var wrt = new JTokenWriter())
            {
                RemoteHelper.GetJson(wrt, document.Root);
                return(wrt.Token);
            }
        }
Esempio n. 5
0
 public List <Account> GetAccountList(List <string> ownerIds)
 {
     if (ownerIds == null || ownerIds.Count == 0)
     {
         return(null);
     }
     else
     {
         byte[] list = RemoteHelper.GetAccountList(ownerIds.ToArray());
         return(We7Helper.BytesToObject(list) as List <Account>);
     }
 }
Esempio n. 6
0
 private void FrmMain_Load(object sender, EventArgs e)
 {
     using (FrmLogon vFrm = new FrmLogon()){
         vFrm.ShowDialog(this);
         this.mServer = RemoteHelper.GetReferenceToServer(this.ServerLocation, vFrm.mDomain, vFrm.mLogin, vFrm.mPass);
     }
     if (mServer == null)
     {
         ShowMessage("Not found (-_-)\r\n" + ServerLocation);
     }
     else
     {
         ShowMessage("Found (^o^)/\r\n" + ServerLocation);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Invokes the given method.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="nodeId"></param>
        /// <param name="interface"></param>
        /// <param name="method"></param>
        /// <param name="params"></param>
        void ClientInvoke(Document document, int nodeId, string @interface, string method, JObject @params)
        {
            Contract.Requires <ArgumentNullException>(document != null);
            Contract.Requires <ArgumentOutOfRangeException>(nodeId > 0);
            Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(@interface));
            Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(method));

            var node = (XNode)document.Xml.ResolveObjectId(nodeId);

            if (node == null)
            {
                return;
            }

            RemoteHelper.Invoke(node, @interface, method, @params);
        }
Esempio n. 8
0
        /// <summary>
        /// Updates the given property.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="nodeId"></param>
        /// <param name="interface"></param>
        /// <param name="property"></param>
        /// <param name="value"></param>
        void ClientUpdate(Document document, int nodeId, string @interface, string property, JValue value)
        {
            Contract.Requires <ArgumentNullException>(document != null);
            Contract.Requires <ArgumentOutOfRangeException>(nodeId > 0);
            Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(@interface));
            Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(property));

            var node = (XNode)document.Xml.ResolveObjectId(nodeId);

            if (node == null)
            {
                return;
            }

            RemoteHelper.Update(node, @interface, property, value);
        }
Esempio n. 9
0
        public void PathSplitting()
        {
            const string path = "ServerConsole.BusinessLogic.JobStates";

            string firstElement;
            var    restOfPath = RemoteHelper.RestOfPath(path, out firstElement);

            Assert.IsTrue(firstElement == "ServerConsole");
            Assert.IsTrue(restOfPath == "BusinessLogic.JobStates");

            restOfPath = RemoteHelper.RestOfPath(restOfPath, out firstElement);
            Assert.IsTrue(firstElement == "BusinessLogic");
            Assert.IsTrue(restOfPath == "JobStates");

            restOfPath = RemoteHelper.RestOfPath(restOfPath, out firstElement);
            Assert.IsTrue(firstElement == "JobStates");
            Assert.IsTrue(restOfPath == "");
        }
        private RemoteHelper GetHelper()
        {
            if (helper == null)
            {
                var assembly = typeof(AppDomainInvoker).GetTypeInfo().Assembly;

                appDomain = AppDomain.CreateDomain(
                    typeof(AppDomainInvoker).FullName,
                    null,
                    new AppDomainSetup
                {
                    ApplicationBase   = Path.GetDirectoryName(assembly.Location),
                    ConfigurationFile = assembly.Location + ".config"
                });

                helper = (RemoteHelper)appDomain.CreateInstanceAndUnwrap(assembly.FullName, typeof(RemoteHelper).FullName);
            }
            return(helper);
        }
Esempio n. 11
0
 public Account GetAccount(string accountID, string[] fields)
 {
     if (accountID == We7Helper.EmptyGUID)
     {
         Account a = new Account();
         a.LoginName = SiteConfigs.GetConfig().AdministratorName;
         a.LastName  = "管理员";
         a.ID        = We7Helper.EmptyGUID;
         return(a);
     }
     else if (accountID == Security.CurrentAccountID)
     {
         if (HttpContext.Current.Session["$We7CurrentAccount"] == null)
         {
             HttpContext.Current.Session["$We7CurrentAccount"] = RemoteHelper.GetAccount(accountID, null);
         }
         return(HttpContext.Current.Session["$We7CurrentAccount"] as Account);
     }
     else
     {
         return(RemoteHelper.GetAccount(accountID, fields));
     }
 }
Esempio n. 12
0
 public Account AddAccount(Account act)
 {
     return(RemoteHelper.AddAccount(act));
 }
Esempio n. 13
0
 public bool ExistEmail(string email)
 {
     return(RemoteHelper.ExistEmail(email));
 }
Esempio n. 14
0
 public List <Department> GetDepartments(string siteID, string parentID, string selectName, string[] fields)
 {
     byte[] list = RemoteHelper.GetDepartments(siteID, parentID, selectName, fields);
     return(We7Helper.BytesToObject(list) as List <Department>);
 }
Esempio n. 15
0
 public List <Department> GetDepartmentTree(string siteID, string parentId)
 {
     byte[] list = RemoteHelper.GetDepartmentTree(siteID, parentId);
     return(We7Helper.BytesToObject(list) as List <Department>);
 }
Esempio n. 16
0
 public List <Role> GetRoles(string siteID, int from, int count)
 {
     byte[] list = RemoteHelper.GetRoles(siteID, from, count);
     return(We7Helper.BytesToObject(list) as List <Role>);
 }
Esempio n. 17
0
 public Department GetDepartment(string departmentID, string[] fields)
 {
     return(RemoteHelper.GetDepartment(departmentID, fields));
 }
Esempio n. 18
0
 public Department AddDepartment(Department dpt)
 {
     return(RemoteHelper.AddDepartment(dpt));
 }
Esempio n. 19
0
 public void UpdateAccount(Account act, string[] fields)
 {
     RemoteHelper.UpdateAccount(act, fields);
 }
Esempio n. 20
0
 public List <string> GetAccountsOfRole(string roleID, int from, int count)
 {
     byte[] list = RemoteHelper.GetAccountsOfRole(roleID, from, count);
     return(We7Helper.BytesToObject(list) as List <string>);
 }
Esempio n. 21
0
 public int GetAccountCountOfRole(string roleID)
 {
     return(RemoteHelper.GetAccountCountOfRole(roleID));
 }
Esempio n. 22
0
 public Role GetRoleBytitle(string title)
 {
     return(RemoteHelper.GetRoleBytitle(title));
 }
Esempio n. 23
0
 public void DeleteAccountRole(string id)
 {
     RemoteHelper.DeleteAccountRole(id);
 }
Esempio n. 24
0
 public List <Role> GetRoles(string siteID, OwnerRank type, string key)
 {
     byte[] list = RemoteHelper.GetRoles(siteID, type, key);
     return(We7Helper.BytesToObject(list) as List <Role>);
 }
Esempio n. 25
0
 public bool ExistUserName(string userName)
 {
     return(RemoteHelper.ExistUserName(userName));
 }
Esempio n. 26
0
 public void DeleteDepartment(string departmentID)
 {
     RemoteHelper.DeleteDepartment(departmentID);
 }
Esempio n. 27
0
 public void DeleteAccont(string accountID)
 {
     RemoteHelper.DeleteAccont(accountID);
 }
Esempio n. 28
0
 public void UpdateDepartment(Department dpt, string[] fields)
 {
     RemoteHelper.UpdateDepartment(dpt, fields);
 }
Esempio n. 29
0
 public List <string> GetRolesOfAccount(string accountID)
 {
     byte[] list = RemoteHelper.GetRolesOfAccount(accountID);
     return(We7Helper.BytesToObject(list) as List <string>);
 }
Esempio n. 30
0
 public int GetRoleCount(string siteID, OwnerRank type)
 {
     return(RemoteHelper.GetRoleCount(siteID, type));
 }