Exemple #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);
     }
 }
Exemple #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 == "");
        }
Exemple #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();
        }
Exemple #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);
            }
        }
Exemple #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>);
     }
 }
Exemple #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);
     }
 }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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));
     }
 }
Exemple #12
0
 public Account AddAccount(Account act)
 {
     return(RemoteHelper.AddAccount(act));
 }
Exemple #13
0
 public bool ExistEmail(string email)
 {
     return(RemoteHelper.ExistEmail(email));
 }
Exemple #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>);
 }
Exemple #15
0
 public List <Department> GetDepartmentTree(string siteID, string parentId)
 {
     byte[] list = RemoteHelper.GetDepartmentTree(siteID, parentId);
     return(We7Helper.BytesToObject(list) as List <Department>);
 }
Exemple #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>);
 }
Exemple #17
0
 public Department GetDepartment(string departmentID, string[] fields)
 {
     return(RemoteHelper.GetDepartment(departmentID, fields));
 }
Exemple #18
0
 public Department AddDepartment(Department dpt)
 {
     return(RemoteHelper.AddDepartment(dpt));
 }
Exemple #19
0
 public void UpdateAccount(Account act, string[] fields)
 {
     RemoteHelper.UpdateAccount(act, fields);
 }
Exemple #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>);
 }
Exemple #21
0
 public int GetAccountCountOfRole(string roleID)
 {
     return(RemoteHelper.GetAccountCountOfRole(roleID));
 }
Exemple #22
0
 public Role GetRoleBytitle(string title)
 {
     return(RemoteHelper.GetRoleBytitle(title));
 }
Exemple #23
0
 public void DeleteAccountRole(string id)
 {
     RemoteHelper.DeleteAccountRole(id);
 }
Exemple #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>);
 }
Exemple #25
0
 public bool ExistUserName(string userName)
 {
     return(RemoteHelper.ExistUserName(userName));
 }
Exemple #26
0
 public void DeleteDepartment(string departmentID)
 {
     RemoteHelper.DeleteDepartment(departmentID);
 }
Exemple #27
0
 public void DeleteAccont(string accountID)
 {
     RemoteHelper.DeleteAccont(accountID);
 }
Exemple #28
0
 public void UpdateDepartment(Department dpt, string[] fields)
 {
     RemoteHelper.UpdateDepartment(dpt, fields);
 }
Exemple #29
0
 public List <string> GetRolesOfAccount(string accountID)
 {
     byte[] list = RemoteHelper.GetRolesOfAccount(accountID);
     return(We7Helper.BytesToObject(list) as List <string>);
 }
Exemple #30
0
 public int GetRoleCount(string siteID, OwnerRank type)
 {
     return(RemoteHelper.GetRoleCount(siteID, type));
 }