Example #1
0
        public IHttpActionResult getTabblesVisibleToUserExceptWs(string uname, string pwd, int sort, int topLevelOnly, int outputTabblesWithInitData, int includeTagsOfSubordinateUsers)
        {
            try
            {
                var db = new tabblesEntities();

                SqlParameter noAuth = null;

                var add = new Action <SqlCommand>(c =>
                {
                    c.Parameters.AddWithValue("@uname", uname);
                    c.Parameters.AddWithValue("@pwd", pwd);
                    c.Parameters.AddWithValue("@sort", sort);
                    c.Parameters.AddWithValue("@topLevelOnly", topLevelOnly);
                    c.Parameters.AddWithValue("@outputTabblesWithInitData", outputTabblesWithInitData == 1 ? true : false);
                    c.Parameters.AddWithValue("@includeTagsOfSubordinateUsers", includeTagsOfSubordinateUsers == 1 ? true : false);


                    noAuth = addOutputParameterInt("@noAuth", c);
                });
                var res = StoredProc.ExecuteStoredProc("getTabblesVisibleToUserExceptWs", add);
                if (res.err == "timeout")
                {
                    return(Ok(new Result {
                        error = "timeout"
                    }));
                }
                else
                {
                    var r = new resultTables(dataTables: res.tables,
                                             noAuth: (int)noAuth.Value,
                                             machineName: null
                                             , obj: null);


                    //var str = Newtonsoft.Json.JsonConvert.SerializeObject(r);

                    return(Ok(new Result {
                        ret = r
                    }));
                }
            }
            catch (Exception e)
            {
                return(Ok(new Result {
                    error = "generic-error", stringOfExc = Utils.stringOfException(e)
                }));
            }
        }
Example #2
0
        public IHttpActionResult getFixedUserData(string uname, string pwd)
        {
            try
            {
                var db = new tabblesEntities();



                SqlParameter noAuth = null;

                var add = new Action <SqlCommand>(c =>
                {
                    c.Parameters.AddWithValue("@uname", uname);
                    c.Parameters.AddWithValue("@pwd", pwd);


                    noAuth = addOutputParameterInt("@noAuth", c);
                });



                var res = StoredProc.ExecuteStoredProc("getFixedUserData", add);


                // devo anche estrarre il machinename to impersonate dall'org e passarlo al client!

                var idorg = int.Parse(res.tables[0].Rows[0]["organization"].ToString());

                var org = db.organization.Where(o => o.id == idorg).FirstOrDefault();

                if (org.machineNameToImpersonate == null)
                {
                    return(Ok(new Result {
                        error = "machine-name-to-impersonate-not-set-for-organization"
                    }));
                }
                else if (res.err == "timeout")
                {
                    return(Ok(new Result {
                        error = "timeout"
                    }));
                }
                else
                {
                    var browser = Utils.GetUserPlatform(HttpContext.Current.Request);

                    var tabblesWebRows = (from ro in db.driveLetterInfoForTabblesWeb
                                          where ro.idOrg == org.id
                                          select new TabblesWebRowForClient
                    {
                        allowDowload = ro.allowDowload,
                        convertAndroid = ro.convertAndroid,
                        convertIos = ro.convertIos,
                        convertLinux = ro.convertLinux,
                        convertMac = ro.convertMac,
                        convertWindows = ro.convertWindows,
                        letter = ro.letter
                    }).ToArray();



                    var r = new resultTables(dataTables: res.tables,
                                             noAuth: (int)noAuth.Value,
                                             machineName: org.machineNameToImpersonate
                                             , obj: null);

                    return(Ok(new Result {
                        ret = r,

                        tabblesWebRows = tabblesWebRows,
                        browser = browser
                    }));
                }
            }
            catch (Exception e)
            {
                return(Ok(new Result {
                    error = "generic-error", stringOfExc = Utils.stringOfException(e)
                }));
            }
        }