Ejemplo n.º 1
0
        // get groupObject row by objectName

        public GroupObject GetGObjByObjName(string objectName, List <GroupObject> GOList)
        {
            GroupObject element = new GroupObject();

            element = GOList.Where(X => X.objectName == objectName).FirstOrDefault();

            return(element);
        }
Ejemplo n.º 2
0
        public async Task <GroupObject> GetByID(int valId)
        {
            GroupObject item = new GroupObject();
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("Id", valId.ToString());
            //#################
            IEnumerable <Claim> claims = await APIResult.getList("GroupObject/GetByID", parameters);

            foreach (Claim c in claims)
            {
                if (c.Type == "scopes")
                {
                    item = JsonConvert.DeserializeObject <GroupObject>(c.Value, new IsoDateTimeConverter {
                        DateTimeFormat = "dd/MM/yyyy"
                    });
                    break;
                }
            }
            return(item);


            //GroupObject Object = new GroupObject();

            //// ... Use HttpClient.
            //ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            //using (var client = new HttpClient())
            //{
            //    ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            //    client.BaseAddress = new Uri(Global.APIUri);
            //    client.DefaultRequestHeaders.Clear();
            //    client.DefaultRequestHeaders.Add("Connection", "Keep-Alive");
            //    client.DefaultRequestHeaders.Add("Keep-Alive", "3600");
            //    HttpRequestMessage request = new HttpRequestMessage();
            //    request.RequestUri = new Uri(Global.APIUri + "GroupObject/GetByID");
            //    request.Headers.Add("Id", valId.ToString());
            //    request.Headers.Add("APIKey", Global.APIKey);
            //    request.Method = HttpMethod.Get;
            //    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            //    var response = await client.SendAsync(request);

            //    if (response.IsSuccessStatusCode)
            //    {
            //        var jsonString = await response.Content.ReadAsStringAsync();

            //        Object = JsonConvert.DeserializeObject<GroupObject>(jsonString);

            //        return Object;
            //    }

            //    return Object;
            //}
        }
Ejemplo n.º 3
0
        public async Task <int> Save(GroupObject newObject)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();
            string method = "GroupObject/Save";

            var myContent = JsonConvert.SerializeObject(newObject);

            parameters.Add("Object", myContent);
            return(await APIResult.post(method, parameters));


            //// ... Use HttpClient.
            //ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            ////
            //var myContent = JsonConvert.SerializeObject(newObject);

            //using (var client = new HttpClient())
            //{
            //    ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            //    client.BaseAddress = new Uri(Global.APIUri);
            //    client.DefaultRequestHeaders.Clear();
            //    client.DefaultRequestHeaders.Add("Connection", "Keep-Alive");
            //    client.DefaultRequestHeaders.Add("Keep-Alive", "3600");
            //    HttpRequestMessage request = new HttpRequestMessage();
            //    // encoding parameter to get special characters
            //    myContent = HttpUtility.UrlEncode(myContent);
            //    request.RequestUri = new Uri(Global.APIUri
            //                                 + "GroupObject/Save?newObject="
            //                                 + myContent);
            //    request.Headers.Add("APIKey", Global.APIKey);
            //    request.Method = HttpMethod.Post;
            //    //set content type
            //    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            //    var response = await client.SendAsync(request);

            //    if (response.IsSuccessStatusCode)
            //    {
            //        var message = await response.Content.ReadAsStringAsync();
            //        message = JsonConvert.DeserializeObject<string>(message);
            //        return message;
            //    }
            //    return "";
            //}
        }
Ejemplo n.º 4
0
        //

        public bool HasPermissionAction(string objectname, List <GroupObject> GOList, string type)
        {
            if (SectionData.isAdminPermision())
            {
                return(true);
            }

            bool hasPermission = false;

            GroupObject groupObject = GetGObjByObjName(objectname, GOList);

            if (groupObject != null)
            {
                if (type == "add" && groupObject.addOb == 1)
                {
                    hasPermission = true;
                }
                else if (type == "update" && groupObject.updateOb == 1)
                {
                    hasPermission = true;
                }
                else if (type == "delete" && groupObject.deleteOb == 1)
                {
                    hasPermission = true;
                }
                else if (type == "show" && groupObject.showOb == 1)
                {
                    hasPermission = true;
                }
                else if (type == "report" && groupObject.reportOb == 1)
                {
                    hasPermission = true;
                }
                else if (type == "one" && groupObject.showOb == 1)
                {
                    hasPermission = true;
                }
            }

            return(hasPermission);
        }
Ejemplo n.º 5
0
        //

        public List <GroupObject> GetObjSons(string objectName, List <GroupObject> GOList)
        {
            objlist = new List <GroupObject>();
            List <GroupObject> opl = new List <GroupObject>();

            // objlist;
            GroupObject firstelement = new GroupObject();

            firstelement = GOList.Where(X => X.objectName == objectName).FirstOrDefault();
            //  firstelement.objectId = objectId;
            if (firstelement != null)
            {
                objlist.Add(firstelement);
                SonsofObject(objlist, GOList);
                return(objlist);
            }
            else
            {
                return(opl);
            }
        }