Пример #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            webServiceLogin = Authentication.CreateLogin(Request);

            var lane        = Request.QueryString["lane"];
            var revision    = Request.QueryString["revision"];
            var storagePref = Request.QueryString["prefer"];
            var preferAzure = !string.IsNullOrEmpty(storagePref) && (storagePref.ToLower() == "azure");

            var baseUrls = preferAzure ? new string[] { AZURE_ROOT_1, AZURE_ROOT_2, NAS_ROOT } : new string[] { NAS_ROOT };

            var step  = 10;
            var limit = 200;

            revision = string.IsNullOrEmpty(revision) ? getLatestRevision(webServiceLogin, lane, step, 0, limit) : revision;

            if (revision != "")
            {
                writeOutput(baseUrls, lane, revision, storagePref);
            }
            else
            {
                throw new HttpException(404, "No Valid Revisions");
            }
        }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            if (Request.QueryString ["username"] != null)
            {
                try {
                    if (!Authentication.Login(Request.QueryString ["username"], Request.QueryString ["pw"], Request, Response))
                    {
                        return;
                    }
                } catch (Exception) {
                    return;
                }
            }

            base.OnLoad(e);

            web_service_login  = Utilities.CreateWebServiceLogin(Context.Request);
            hoststatusresponse = Utils.WebService.GetHostStatus(web_service_login);


            var node_information = new Dictionary <string, object> {
                { "inactiveNodes", GetInactiveNodes(web_service_login, hoststatusresponse) },
                { "activeNodes", GetActiveNodes(web_service_login, hoststatusresponse) },
                { "downNodes", GetDownNodes(web_service_login, hoststatusresponse) },
                // { "pendingJobs", "asdf" }
            };

            Response.Write(JsonConvert.SerializeObject(node_information, Formatting.Indented));
        }
Пример #3
0
        private WebServiceLogin CreateLogin()
        {
            WebServiceLogin login = new WebServiceLogin();

            login.Cookie   = Request ["cookie"];
            login.Password = Request ["password"];
            if (string.IsNullOrEmpty(login.Cookie))
            {
                if (Request.Cookies ["cookie"] != null)
                {
                    login.Cookie = Request.Cookies ["cookie"].Value;
                }
            }

            login.User = Request ["user"];
            if (string.IsNullOrEmpty(login.User))
            {
                if (Request.Cookies ["user"] != null)
                {
                    login.User = Request.Cookies ["user"].Value;
                }
            }

            login.Ip4 = Request ["ip4"];
            if (string.IsNullOrEmpty(login.Ip4))
            {
                login.Ip4 = Utilities.GetExternalIP(Request);
            }

            return(login);
        }
Пример #4
0
        bool isValidRevision(WebServiceLogin login, List <DBRevisionWork> revisionWorkList)
        {
            Func <DBRevisionWork, bool> validRevisions = r =>
                                                         Utils.LocalWebService.GetViewLaneData(login, r.lane_id, "", r.host_id, "", r.revision_id, "").WorkViews.Any(isValid);

            return(revisionWorkList.Any(validRevisions));
        }
Пример #5
0
        private void DownloadRevisionLog(int revision_id, bool diff /* diff or log */)
        {
            DBRevision revision;
            DBLane     lane;

            using (DB db = new DB()) {
                WebServiceLogin login = Authentication.CreateLogin(Request);

                revision = DBRevision_Extensions.Create(db, revision_id);

                // no access restricion on revision logs/diffs
                Authentication.VerifyAnonymousAccess(Context, db, login);

                Response.ContentType = MimeTypes.TXT;

                if (revision == null)
                {
                    Response.Write("Revision not found.");
                }
                else
                {
                    lane = DBLane_Extensions.Create(db, revision.lane_id);
                    using (Process git = new Process()) {
                        git.StartInfo.RedirectStandardOutput = true;
                        git.StartInfo.RedirectStandardError  = true;
                        git.StartInfo.UseShellExecute        = false;
                        git.StartInfo.FileName = "git";
                        if (diff)
                        {
                            git.StartInfo.Arguments = "diff --no-color --no-prefix " + revision.revision + "~ " + revision.revision;
                        }
                        else
                        {
                            git.StartInfo.Arguments = "log -1 --no-color --no-prefix " + revision.revision;
                        }
                        git.StartInfo.WorkingDirectory = Configuration.GetSchedulerRepositoryCacheDirectory(lane.repository);
                        git.OutputDataReceived        += (object sender, DataReceivedEventArgs ea) =>
                        {
                            Response.Write(ea.Data);
                            Response.Write('\n');
                        };
                        git.ErrorDataReceived += (object sender, DataReceivedEventArgs ea) =>
                        {
                            Response.Write(ea.Data);
                            Response.Write('\n');
                        };
                        // Logger.Log ("Executing: '{0} {1}' in {2}", git.StartInfo.FileName, git.StartInfo.Arguments, git.StartInfo.WorkingDirectory);
                        git.Start();
                        git.BeginErrorReadLine();
                        git.BeginOutputReadLine();
                        if (!git.WaitForExit(1000 * 60 * 5 /* 5 minutes */))
                        {
                            git.Kill();
                            Response.Write("Error: git diff didn't finish in 5 minutes, aborting.\n");
                        }
                    }
                }
            }
        }
Пример #6
0
 /// <summary>
 /// Verify that the user is a valid user if anonymous access isn't allowed
 /// </summary>
 /// <param name="Context"></param>
 /// <param name="db"></param>
 /// <param name="login"></param>
 public static void VerifyAnonymousAccess(HttpContext Context, DB db, WebServiceLogin login)
 {
     if (Configuration.AllowAnonymousAccess)
     {
         return;
     }
     Authenticate(Context, db, login, null, true);
 }
Пример #7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            webServiceLogin = Authentication.CreateLogin(Request);

            Response.AppendHeader("Access-Control-Allow-Origin", "*");
            Response.AppendHeader("Content-Type", "text/plain");
            Response.StatusCode = 404;
            Response.Write("GetLatest is deprecated, please use http://wrench.internalx.com/Wrench/GetManifest.aspx or http://wrench.internalx.com/Wrench/GetMetadata.aspx");
        }
Пример #8
0
        public static void LoginDB(DB db, LoginResponse response, string username, string roles, string ip4)
        {
            // We now create an account with an empty password and the specified roles.
            // Note that it is not possible to log into an account with an empty password
            // using the normal login procedure.

            DBPerson open_person = null;

            using (IDbCommand cmd = db.CreateCommand()) {
                cmd.CommandText = @"SELECT * FROM Person WHERE login = @login;";
                DB.CreateParameter(cmd, "login", username);
                using (var reader = cmd.ExecuteReader()) {
                    if (reader.Read())
                    {
                        open_person = new DBPerson(reader);
                    }
                }
            }

            if (open_person == null)
            {
                open_person       = new DBPerson();
                open_person.login = username;
                open_person.roles = roles;
                open_person.Save(db);
            }
            else
            {
                // only save if something has changed
                if (open_person.roles != roles)
                {
                    open_person.roles = roles;
                    open_person.Save(db);
                }
            }
            WebServiceLogin login = new WebServiceLogin();

            login.Ip4  = ip4;
            login.User = open_person.login;
            db.Audit(login, "DBLogin_Extensions.Login (username: {0}, ip4: {1})", username, ip4);

            var result = new DBLogin();

            result.person_id = open_person.id;
            result.ip4       = ip4;
            result.cookie    = CreateCookie();
            result.expires   = DateTime.Now.AddDays(1);
            result.Save(db);

            response.User      = username;
            response.UserName  = username;
            response.UserRoles = open_person.Roles;
            response.Cookie    = result.cookie;
        }
Пример #9
0
        public static void VerifyUserInRole(HttpContext Context, DB db, WebServiceLogin login, string role, bool @readonly)
        {
            WebServiceResponse dummy = new WebServiceResponse();

            Authenticate(Context, db, login, dummy, @readonly);

            if (!dummy.IsInRole(role))
            {
                Logger.Log(2, "The user '{0}' has the roles '{1}', and requested role is: {2}", login.User, dummy.UserRoles == null ? "<null>" : string.Join(",", dummy.UserRoles), role);
                throw new HttpException(403, "You don't have the required permissions.");
            }
        }
Пример #10
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            webServiceLogin = Authentication.CreateLogin(Request);

            var laneName    = Request.QueryString ["laneName"];
            var baseURL     = Request.QueryString ["url"] ?? "http://storage.bos.internalx.com";
            var storagePref = Request.QueryString ["prefer"];

            if (!string.IsNullOrEmpty(storagePref) && (storagePref.ToLower() == "azure"))
            {
                baseURL = "https://bosstoragemirror.blob.core.windows.net";
            }
            var updateRequest = false;
            var step          = 10;
            var limit         = 200;

            var revision = getLatestRevision(webServiceLogin, laneName, step, 0, limit);

            Action handleGetLatest = () => {
                Response.AppendHeader("Access-Control-Allow-Origin", "*");
                Response.AppendHeader("Content-Type", "text/plain");

                HttpWebResponse response = makeHttpRequest(getManifestUrl(baseURL, laneName, revision));
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    // Default to NAS
                    if (storagePref != "NAS")
                    {
                        response = makeHttpRequest(getManifestUrl("http://storage.bos.internalx.com", laneName, revision));
                        if (response.StatusCode != HttpStatusCode.OK)
                        {
                            Response.Write("Can't find manifest");
                            return;
                        }
                    }
                    Response.Write("Can't find manifest");
                    return;
                }
                using (var reader = new StreamReader(response.GetResponseStream())) {
                    Response.Write(reader.ReadToEnd());
                }
            };

            if (revision != "")
            {
                handleGetLatest();
            }
            else
            {
                Response.Write("No Valid Revisions");
            }
        }
Пример #11
0
        public static void VerifyUserInRole(string remote_ip, DB db, WebServiceLogin login, string role, bool @readonly)
        {
            WebServiceResponse dummy = new WebServiceResponse();

            Authenticate(remote_ip, db, login, dummy, @readonly);

            if (!dummy.IsInRole(role))
            {
                log.InfoFormat("The user '{0}' has the roles '{1}', and requested role is: {2}", login.User, dummy.UserRoles == null ? "<null>" : string.Join(",", dummy.UserRoles), role);
                throw new UnauthorizedException("You don't have the required permissions.");
            }
        }
Пример #12
0
        /// <summary>
        /// 测试webservice数据库连接
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public JObject JoinWebService(HttpContext context)
        {
            JObject         obj     = new JObject();
            YZRequest       request = new YZRequest(context);
            WebServiceLogin login   = new WebServiceLogin();

            login.webPath = request.GetString("webPath");
            string message = null;
            bool   flag    = CommonHandle.IsWebServiceJoin(login, out message);

            obj[YZJsonProperty.success]      = true;
            obj[YZJsonProperty.errorMessage] = flag ? "连接成功!" : String.Format("连接失败!原因:<br/>{0}", message);
            return(obj);
        }
Пример #13
0
        public static string CreateWebServiceDownloadUrl(int workfile_id, WebServiceLogin login, bool redirect)
        {
            string uri = CreatePage("Download.aspx");

            uri += "?";
            uri += "workfile_id=" + workfile_id.ToString();
            if (!redirect)
            {
                uri += "&cookie=" + login.Cookie;
                uri += "&ip4=" + login.Ip4;
                uri += "&user=" + login.User;
            }
            return(uri);
        }
Пример #14
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            login = Authentication.CreateLogin(Request);

            requestType = Request.QueryString ["type"];
            limit       = Utils.TryParseInt32(Request.QueryString ["limit"]) ?? 50;
            offset      = Utils.TryParseInt32(Request.QueryString ["offset"]) ?? 0;

            Response.AppendHeader("Access-Control-Allow-Origin", "*");
            switch (requestType)
            {
            case "laneinfo":
                Response.Write(GetLaneInfo());
                break;

            case "taginfo":
                Response.Write(GetTagInfo());
                break;

            case "botinfo":
                GetBotInfo();
                break;

            case "stephistory":
                Response.Write(GetStepHistory());
                break;

            case "botstatus":
                Response.Write(GetBotStatusTimes());
                break;

            case "jobinfo":
                Response.Write(GetJobInfo());
                break;

            case "stepinfo":
                Response.Write(GetStepInfo());
                break;

            case "frontpage":
                Response.Write(GetFrontPage());
                break;

            default:
                GetBotStatus();
                break;
            }
        }
Пример #15
0
        private List <string> GetDownNodes(WebServiceLogin web_service_login, GetHostStatusResponse hoststatusresponse)
        {
            var down = new List <string> ();

            for (int i = 0; i < hoststatusresponse.HostStatus.Count; i++)
            {
                var status = hoststatusresponse.HostStatus [i];

                if (NodeIsDead(status))
                {
                    down.Add(status.host);
                }
            }
            return(down);
        }
Пример #16
0
        private void DownloadNamedWorkFile(int work_id, string filename)
        {
            DBWorkFileView view = null;
            DBFile         file = null;
            string         compressed_mime;

            using (DB db = new DB()) {
                WebServiceLogin login = Authentication.CreateLogin(Request);

                view = DBWorkFileView_Extensions.Find(db, work_id, filename);

                if (view == null)
                {
                    throw new HttpException(404, "Could not find the file.");
                }

                if (view.@internal)                 // internal files need admin rights
                {
                    Authentication.VerifyUserInRole(Context, db, login, Roles.Administrator, false);
                }
                else
                {
                    Authentication.VerifyAnonymousAccess(Context, db, login);
                }

                file = DBWork_Extensions.GetFile(db, view.work_id, filename, false);
                if (file == null)
                {
                    throw new HttpException(404, string.Format("Could not find the filename '{0}'", filename));
                }

                compressed_mime = file.compressed_mime;

                Response.ContentType = file.mime;
                Response.AppendHeader("Content-Disposition", "filename=\"" + Path.GetFileName(filename) + "\"");

                if (view.file_file_id == null)
                {
                    DownloadMd5(view.md5);
                }
                else
                {
                    using (Stream str = db.Download(view)) {
                        DownloadStream(str, compressed_mime);
                    }
                }
            }
        }
Пример #17
0
        public static WebServiceLogin CreateWebServiceLogin(HttpRequest Request)
        {
            WebServiceLogin web_service_login;

            web_service_login        = new WebServiceLogin();
            web_service_login.Cookie = GetCookie(Request, "cookie");
            if (HttpContext.Current.User != null)
            {
                web_service_login.User = GetCookie(Request, "user");
            }
            web_service_login.Ip4 = GetExternalIP(Request);

            // Console.WriteLine ("Master, Cookie: {0}, User: {1}", web_service_login.Cookie, web_service_login.User);

            return(web_service_login);
        }
Пример #18
0
        private List <string> GetInactiveNodes(WebServiceLogin web_service_login, GetHostStatusResponse hoststatusresponse)
        {
            var idles = new List <string> ();

            for (int i = 0; i < hoststatusresponse.HostStatus.Count; i++)
            {
                var status = hoststatusresponse.HostStatus [i];
                var idle   = string.IsNullOrEmpty(status.lane);

                if (idle && !NodeIsDead(status))
                {
                    idles.Add(status.host);
                }
            }
            return(idles);
        }
Пример #19
0
        protected override void OnLoad(EventArgs e)
        {
            var start = DateTime.Now;

            base.OnLoad(e);
            login = Authentication.CreateLogin(Request);
            Response.AppendHeader("Access-Control-Allow-Origin", "*");
            Dictionary <String, Object> buildStatusResponse = null;

            try {
                if (!string.IsNullOrEmpty(Request ["lane_id"]))
                {
                    var laneId     = Utils.TryParseInt32(Request ["lane_id"]);
                    var revisionId = Utils.TryParseInt32(Request ["revision_id"]);
                    if (laneId.HasValue && revisionId.HasValue)
                    {
                        buildStatusResponse = FetchBuildStatus(laneId.Value, revisionId.Value);
                    }
                }
                else
                {
                    var laneName = Request ["lane_name"];
                    var commit   = Request ["commit"];
                    if (string.IsNullOrEmpty(laneName) || string.IsNullOrEmpty(commit))
                    {
                        ThrowJsonError(400, "Either lane_name+commit or lane_id+revision_id must be provided to resolve build.");
                    }
                    buildStatusResponse = FetchBuildStatus(laneName, commit);
                }
                buildStatusResponse.Add("generation_time", (DateTime.Now - start).TotalMilliseconds);
                Response.Write(JsonConvert.SerializeObject(buildStatusResponse));
            } catch (System.Web.Services.Protocols.SoapException) {
                Response.StatusCode = 403;
                Response.Write(JsonConvert.SerializeObject(new Dictionary <String, String> {
                    {
                        "error",
                        "You are not authorized to use this resource."
                    }
                }));
            } catch (HttpException exp) {
                Response.StatusCode = exp.GetHttpCode();
                Response.Write(exp.Message);
            } finally {
                Response.Flush();
                Response.Close();
            }
        }
Пример #20
0
        /// <summary>
        /// 获取参数
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public JObject GetParameter(HttpContext context)
        {
            JObject obj = new JObject();

            try
            {
                YZRequest request = new YZRequest(context);
                //获取数据连接信息
                int             connectId = request.GetInt32("connectId");
                ConnectInfo     con       = ConnectInfoManager.GetConnectInfo(connectId);
                WebServiceLogin login     = JObject.Parse(con.connectStr).ToObject <WebServiceLogin>();
                ISourceHandle   handle    = new WebServiceHandle(login);
                //获取接口信息
                string          functionName = request.GetString("functionName");
                QueryDepictInfo info         = handle.GetQueryInfo(functionName);
                //序列化
                JArray parameterArray = new JArray();
                obj["parameter"] = parameterArray;
                if (info.parameter != null && info.parameter.Count > 0)
                {
                    if (CommonHandle.IsParameterNoType(info.parameter))
                    {
                        obj[YZJsonProperty.success]      = false;
                        obj[YZJsonProperty.errorMessage] = "输入参数中有不符合规定的类型,无法进行配置!";
                        return(obj);
                    }
                    foreach (ColumnInfo item in info.parameter)
                    {
                        parameterArray.Add(BizCommon.GetColumnJson(item));
                    }
                }
                if (info.schema == null)
                {
                    obj[YZJsonProperty.success]      = false;
                    obj[YZJsonProperty.errorMessage] = "该接口没有返回值,不可调用!";
                    return(obj);
                }
                obj[YZJsonProperty.success] = true;
                return(obj);
            }
            catch (Exception ex)
            {
                obj[YZJsonProperty.success]      = false;
                obj[YZJsonProperty.errorMessage] = ex.ToString();
                return(obj);
            }
        }
Пример #21
0
        string getLatestRevision(WebServiceLogin login, string laneName, int step, int offset, int limit)
        {
            var lane           = Utils.LocalWebService.FindLane(login, null, laneName).lane;
            var revisions      = Utils.LocalWebService.GetRevisions(login, null, laneName, step, offset).Revisions;
            var revisionWorks  = revisions.Select(r => Utils.LocalWebService.GetRevisionWorkForLane(login, lane.id, r.id, -1).RevisionWork).ToList();
            var validRevisions = revisionWorks.Find(wl => isValidRevision(login, wl));

            if (validRevisions != null)
            {
                return(getRevisionName(revisions, validRevisions.First().revision_id));
            }
            else if (offset < limit)
            {
                return(getLatestRevision(login, laneName, step, offset + step, limit));
            }
            else
            {
                return("");
            }
        }
Пример #22
0
    public static bool Login(string user, string password, HttpRequest Request, HttpResponse Response)
    {
        LoginResponse response;

        WebServiceLogin login = new WebServiceLogin();

        login.User     = user;
        login.Password = password;

        login.Ip4 = MonkeyWrench.Utilities.GetExternalIP(Request);
        response  = Utils.WebService.Login(login);
        if (response == null)
        {
            Logger.Log("Login failed");
            return(false);
        }
        else
        {
            SetCookies(Response, response);
            return(true);
        }
    }
Пример #23
0
    public static bool Login(string user, string password, HttpRequest Request, HttpResponse Response)
    {
        LoginResponse response;

        WebServiceLogin login = new WebServiceLogin();

        login.User     = user;
        login.Password = password;

        login.Ip4 = Utilities.GetExternalIP(Request);
        response  = Utils.LocalWebService.Login(login);
        if (response == null)
        {
            log.InfoFormat("Login for {0} at {1} failed.", login.User, login.Ip4);
            return(false);
        }
        else
        {
            log.InfoFormat("Login for {0} at {1} succeeded.", login.User, login.Ip4);
            SetCookies(Response, response);
            return(true);
        }
    }
Пример #24
0
        public static void VerifyUserInRoles(HttpContext Context, DB db, WebServiceLogin login, string[] roles, bool @readonly)
        {
            WebServiceResponse dummy = new WebServiceResponse();

            Authenticate(Context, db, login, dummy, @readonly);

            foreach (var role in roles)
            {
                if (string.IsNullOrEmpty(role))
                {
                    continue;
                }
                if (dummy.IsInRole(role))
                {
                    return;
                }
            }

            var userRoles      = dummy.UserRoles == null ? "<null>" : string.Join(",", dummy.UserRoles);
            var requestedRoles = roles == null ? "<null>" : string.Join(",", roles);

            log.InfoFormat("The user '{0}' has the roles '{1}', and requested roles are: {2}", login.User, userRoles, requestedRoles);
            throw new UnauthorizedException("You don't have the required permissions.");
        }
Пример #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string action   = Request ["action"];
        string referrer = Request ["referrer"] ?? (string)Session ["login_referrer"];

        Session.Remove("login_referrer");
        bool noOpenIdResponse = false;

        if (!string.IsNullOrEmpty(referrer))
        {
            txtReferrer.Value = referrer;
        }

        if (!this.IsPostBack)
        {
            if (Request.UrlReferrer != null && string.IsNullOrEmpty(txtReferrer.Value))
            {
                txtReferrer.Value = Request.UrlReferrer.AbsoluteUri;
            }
        }

        // can't refer back to itself
        if (txtReferrer.Value.Contains("Login.aspx"))
        {
            txtReferrer.Value = "index.aspx";
        }

        cmdLoginOpenId.Visible      = !string.IsNullOrEmpty(Configuration.OpenIdProvider);
        cmdLoginOauth.Visible       = !string.IsNullOrEmpty(Configuration.OauthClientId);
        cmdLoginGitHubOauth.Visible = !string.IsNullOrEmpty(Configuration.GitHubOauthClientId);

        if (!Configuration.AllowPasswordLogin)
        {
            cmdLogin.Visible    = Configuration.AllowPasswordLogin;
            txtPassword.Visible = Configuration.AllowPasswordLogin;
            txtUser.Visible     = Configuration.AllowPasswordLogin;
            lblUser.Visible     = Configuration.AllowPasswordLogin;
            lblPassword.Visible = Configuration.AllowPasswordLogin;
        }

        // If we have a provider of GitHub in the query string,
        // try to log in using our Oauth session state.
        if (cmdLoginGitHubOauth.Visible &&
            Request.QueryString.GetValues("__provider__") != null &&
            Request.QueryString.GetValues("__provider__")[0] == "github")
        {
            var authResult = GitHubAuthenticationHelper.VerifyAuthentication();
            if (!authResult.IsSuccessful)
            {
                lblMessageOpenId.Text = "Failed to get user authenication from GitHub";
                return;
            }

            var accessToken       = authResult.GetAccessToken();
            var userTeamList      = GitHubAuthenticationHelper.GetUserTeams(accessToken);
            var gitHubOrgTeamList = new List <string[]> ();
            // We can't use select/group by with dynamic objects.
            // So instead, we put together the org and team list ourselves as a tuple.
            foreach (var userTeam in userTeamList)
            {
                var teamName = userTeam.name.ToString();
                var orgName  = userTeam.organization.login.ToString();
                gitHubOrgTeamList.Add(new string[] { orgName, teamName });
            }

            LoginResponse loginResponse = new LoginResponse();
            using (DB db = new DB()) {
                try {
                    DBLogin_Extensions.GitHubLogin(db, loginResponse,
                                                   Utilities.GetExternalIP(Request),
                                                   gitHubOrgTeamList,
                                                   authResult.GetGitHubLogin());
                } catch (Exception ex) {
                    loginResponse.Exception = new WebServiceException(ex);
                }
            }
            if (loginResponse.Exception != null)
            {
                lblMessageOpenId.Text = loginResponse.Exception.Message;
            }
            else
            {
                Authentication.SetCookies(Response, loginResponse);
                Response.Redirect(txtReferrer.Value, false);
            }

            Session["github_token"] = accessToken;
            return;
        }

        // If "state" is in the query string callback, it's Google OAuth, so try to log in with that

        if (cmdLoginOauth.Visible && Request.QueryString.GetValues("state") != null)
        {
            var authResult = AuthenticationHelper.VerifyAuthentication();
            if (!authResult.IsSuccessful)
            {
                lblMessageOpenId.Text = "Failed to get user authenication from Google";
                return;
            }

            LoginResponse loginResponse = new LoginResponse();
            using (DB db = new DB()) {
                try {
                    DBLogin_Extensions.Login(db, loginResponse, authResult.GetEmail(),
                                             Utilities.GetExternalIP(Request));
                } catch (Exception ex) {
                    loginResponse.Exception = new WebServiceException(ex);
                }
            }
            if (loginResponse.Exception != null)
            {
                lblMessageOpenId.Text = loginResponse.Exception.Message;
            }
            else
            {
                Authentication.SetCookies(Response, loginResponse);
                Response.Redirect(txtReferrer.Value, false);
            }
            return;
        }

        if (cmdLoginOpenId.Visible)
        {
            OpenIdRelyingParty openid = new OpenIdRelyingParty();
            var oidresponse           = openid.GetResponse();
            if (oidresponse != null)
            {
                switch (oidresponse.Status)
                {
                case AuthenticationStatus.Authenticated:
                    // This is where you would look for any OpenID extension responses included
                    // in the authentication assertion.
                    var    fetch = oidresponse.GetExtension <FetchResponse> ();
                    string email;

                    email = fetch.Attributes [WellKnownAttributes.Contact.Email].Values [0];

                    WebServiceLogin login = new WebServiceLogin();
                    login.Password = Configuration.WebServicePassword;
                    login.User     = Configuration.Host;
                    var response = Utils.LocalWebService.LoginOpenId(login, email, Utilities.GetExternalIP(Request));
                    if (response.Exception != null)
                    {
                        lblMessageOpenId.Text = response.Exception.Message;
                    }
                    else
                    {
                        Authentication.SetCookies(Response, response);
                        Response.Redirect(txtReferrer.Value, false);
                        return;
                    }
                    break;

                default:
                    lblMessageOpenId.Text = "Could not login using OpenId: " + oidresponse.Status.ToString();
                    break;
                }
            }
            else
            {
                noOpenIdResponse = true;
            }
        }

        if (!string.IsNullOrEmpty(action) && action == "logout")
        {
            if (Request.Cookies ["cookie"] != null)
            {
                Utils.LocalWebService.Logout(Master.WebServiceLogin);
                Response.Cookies.Add(new HttpCookie("cookie", ""));
                Response.Cookies ["cookie"].Expires = DateTime.Now.AddYears(-20);
                Response.Cookies.Add(new HttpCookie("user", ""));
                Response.Cookies ["user"].Expires = DateTime.Now.AddYears(-20);
                Response.Cookies.Add(new HttpCookie("roles", ""));
                Response.Cookies ["roles"].Expires = DateTime.Now.AddYears(-20);
            }
            Response.Redirect(txtReferrer.Value, false);
            return;
        }

        var auto_openid_redirect = false;
        var auto = Request ["auto-redirect-openid"];

        if (!string.IsNullOrEmpty(auto) && auto.ToUpperInvariant() == "TRUE")
        {
            auto_openid_redirect = true;
        }

        if (!Configuration.AllowPasswordLogin && string.IsNullOrEmpty(action) && Configuration.AllowAnonymousAccess && noOpenIdResponse)
        {
            auto_openid_redirect = true;
        }

        if (auto_openid_redirect)
        {
            cmdLoginOpenId_Click(null, null);
        }
    }
Пример #26
0
    int Run(String[] args)
    {
        if (!Configuration.LoadConfiguration(new string[0]))
        {
            Console.WriteLine("Couldn't load configuration.");
            return(1);
        }
        ws = WebServices.Create();
        ws.CreateLogin(Configuration.Host, Configuration.WebServicePassword);
        login = ws.WebServiceLogin;
        ws.Login(login);

        string command = args.Length > 0 ? args [0] : "";

        if (command == "lane-config")
        {
            // Requires admin rights (because it uses GetLaneForEdit)
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: lane-config <lane name>");
                return(1);
            }
            string lane_name = args [1];
            var    lane      = FindLaneByName(lane_name);
            if (lane == null)
            {
                return(1);
            }
            Console.WriteLine("Lane: " + lane.lane);
            if (lane.parent_lane_id != null)
            {
                var parent_lane = ws.FindLane(login, lane.parent_lane_id, null).lane;
                if (parent_lane != null)
                {
                    Console.WriteLine("Parent: " + parent_lane.lane);
                }
            }
            Console.WriteLine("Source control: " + lane.source_control);
            Console.WriteLine("Repository: " + lane.repository);
            Console.WriteLine("Mini/Max revision: " + lane.min_revision + "/" + (lane.max_revision != "" ? lane.max_revision : "<none>"));

            var res = ws.GetLaneForEdit(login, lane.id, null);
            foreach (var c in res.Commands)
            {
                Console.WriteLine("\t " + c.sequence + " " + c.command + " (" + c.filename + " " + c.arguments + ")");
            }
            Console.WriteLine("Files:");
            foreach (var f in res.Files)
            {
                Console.WriteLine("\t" + f.name);
            }
            Console.WriteLine("Hosts:");
            foreach (var h in res.HostLaneViews)
            {
                Console.WriteLine("\t" + h.host);
            }
        }
        else if (command == "show-step")
        {
            // Requires admin rights
            if (args.Length < 3)
            {
                Console.WriteLine("Usage: show-step <lane> <step name>");
                return(1);
            }
            string lane_name = args [1];
            string cmd_name  = args [2];
            var    lane      = FindLaneByName(lane_name);
            if (lane == null)
            {
                return(1);
            }
            var cmd = FindCmdByName(lane, cmd_name);
            if (cmd == null)
            {
                return(1);
            }
            PrintCmd(cmd);
        }
        else if (command == "add-step")
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Usage: add-step <lane> <step name>");
                return(1);
            }
            string lane_name = args [1];
            string cmd_name  = args [2];
            var    lane      = FindLaneByName(lane_name);
            if (lane == null)
            {
                return(1);
            }
            if (!CheckCmdExists(lane, cmd_name))
            {
                return(1);
            }
            bool always   = true;
            bool nonfatal = true;
            int  timeout  = 5;
            // FIXME: AddCommand () ignores this
            int seq = 0;
            ws.AddCommand(login, lane.id, cmd_name, always, nonfatal, timeout, seq);
        }
        else if (command == "edit-step")
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Usage: edit-step <lane> <step name> [<edit options>]");
                return(1);
            }
            string lane_name = args [1];
            string cmd_name  = args [2];
            var    lane      = FindLaneByName(lane_name);
            if (lane == null)
            {
                return(1);
            }
            var cmd = FindCmdByName(lane, cmd_name);
            if (cmd == null)
            {
                return(1);
            }

            int?      seq           = null;
            int?      timeout       = null;
            bool      nonfatal      = cmd.nonfatal;
            bool      alwaysexecute = cmd.alwaysexecute;
            string    filename      = null;
            string    arguments     = null;
            string    upload_files  = null;
            OptionSet p             = new OptionSet()
                                      .Add("seq=", v => seq                     = Int32.Parse(v))
                                      .Add("timeout=", v => timeout             = Int32.Parse(v))
                                      .Add("nonfatal=", v => nonfatal           = Boolean.Parse(v))
                                      .Add("alwaysexecute=", v => alwaysexecute = Boolean.Parse(v))
                                      .Add("filename=", v => filename           = v)
                                      .Add("arguments=", v => arguments         = v)
                                      .Add("upload-files=", v => upload_files   = v);
            var new_args = p.Parse(args.Skip(3).ToArray());
            if (new_args.Count > 0)
            {
                Console.WriteLine("Unknown arguments: " + String.Join(" ", new_args.ToArray()));
                return(1);
            }

            PrintCmd(cmd);

            if (seq != null)
            {
                ws.EditCommandSequence(login, cmd.id, (int)seq);
            }
            if (filename != null)
            {
                ws.EditCommandFilename(login, cmd.id, filename);
            }
            if (arguments != null)
            {
                ws.EditCommandArguments(login, cmd.id, arguments);
            }
            if (upload_files != null)
            {
                ws.EditCommandUploadFiles(login, cmd.id, upload_files);
            }
            if (timeout != null)
            {
                ws.EditCommandTimeout(login, cmd.id, (int)timeout);
            }
            if (alwaysexecute != cmd.alwaysexecute)
            {
                ws.SwitchCommandAlwaysExecute(login, cmd.id);
            }
            if (nonfatal != cmd.nonfatal)
            {
                ws.SwitchCommandNonFatal(login, cmd.id);
            }

            cmd = FindCmdByName(lane, cmd_name);
            if (cmd == null)
            {
                return(1);
            }
            Console.WriteLine("=>");
            PrintCmd(cmd);
        }
        else if (command == "add-lane-file")
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Usage: add-lane-file <lane> <lane file name>");
                return(1);
            }
            string lane_name      = args [1];
            string lane_file_name = args [2];
            var    lane           = FindLaneByName(lane_name);
            if (lane == null)
            {
                return(1);
            }
            var res  = ws.GetLaneForEdit(login, lane.id, null);
            var file = (from f in res.Files where f.name == lane_file_name select f).FirstOrDefault();
            if (file != null)
            {
                Console.WriteLine("A file named '" + lane_file_name + "' already exists in lane '" + lane.lane + "'.");
                return(1);
            }
            ws.CreateLanefile(login, lane.id, lane_file_name);
        }
        else if (command == "edit-lane-file")
        {
            if (args.Length < 4)
            {
                Console.WriteLine("Usage: edit-lane-file <lane> <lane file name> <filename>");
                return(1);
            }
            string lane_name      = args [1];
            string lane_file_name = args [2];
            string filename       = args [3];
            var    lane           = FindLaneByName(lane_name);
            if (lane == null)
            {
                return(1);
            }

            var res  = ws.GetLaneForEdit(login, lane.id, null);
            var file = (from f in res.Files where f.name == lane_file_name select f).FirstOrDefault();
            if (file == null)
            {
                Console.WriteLine("No file named '" + lane_file_name + "' in lane '" + lane.lane + "'.");
                return(1);
            }

            file.contents = File.ReadAllText(filename);
            ws.EditLaneFile(login, file);
        }
        else if (command == "lanes")
        {
            var res = ws.GetLanes(login);
            foreach (var l in res.Lanes)
            {
                Console.WriteLine(l.lane);
            }
        }
        else if (command == "lane-tree")
        {
            var res  = ws.GetLanes(login);
            var tree = new Dictionary <DBLane, List <DBLane> > ();
            foreach (var l in res.Lanes)
            {
                tree [l] = new List <DBLane> ();
            }
            foreach (var l in res.Lanes)
            {
                if (l.parent_lane_id != null)
                {
                    var parent_lane = (from l2 in res.Lanes where l2.id == l.parent_lane_id select l2).First();
                    tree [parent_lane].Add(l);
                }
            }
            foreach (var l in tree.Keys)
            {
                if (l.parent_lane_id == null)
                {
                    PrintLaneTree(tree, l, 0);
                }
            }
        }
        else if (command == "rev")
        {
            if (args.Length < 4)
            {
                Console.WriteLine("Usage: rev <lane> <host> <revision>");
                return(1);
            }
            string lane_name = args [1];
            string host_name = args [2];
            string rev_name  = args [3];

            var lane = ws.FindLane(login, null, lane_name).lane;
            if (lane == null)
            {
                Console.WriteLine("Lane '" + lane_name + "' not found.");
                return(1);
            }
            var host = ws.FindHost(login, null, host_name).Host;
            var res  = ws.FindRevisionForLane(login, null, rev_name, lane.id, null);
            var rev  = res.Revision;
            if (res.Revision == null)
            {
                Console.WriteLine("Revision '" + rev_name + "' not found.");
                return(1);
            }
            var res2 = ws.GetViewLaneData(login, lane.id, null, host.id, null, rev.id, null);
            Console.WriteLine("" + rev.revision + " " + rev.author + " " + (DBState)res2.RevisionWork.state);
            int vindex = 0;
            foreach (var view in res2.WorkViews)
            {
                Console.WriteLine("\t " + view.command + " " + (DBState)view.state);
                foreach (var fview in res2.WorkFileViews[vindex])
                {
                    if (fview.work_id == view.id)
                    {
                        Console.WriteLine("\t\t" + fview.filename);
                    }
                }
                vindex++;
            }
        }
        else if (command == "lane")
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Usage: lane <lane> <host>");
                return(1);
            }

            string lane_name = args [1];
            string host_name = args [2];

            int       limit = 10;
            OptionSet p     = new OptionSet()
                              .Add("limit=", v => limit = Int32.Parse(v));
            p.Parse(args.Skip(3).ToArray());

            var lane = ws.FindLane(login, null, lane_name).lane;
            if (lane == null)
            {
                Console.WriteLine("Lane '" + lane_name + "' not found.");
                return(1);
            }
            //var cmds = ws.GetCommands (login, lane.id);
            //var cmd = (from c in cmds.Commands where c.command == "package" select c).First ();
            var hosts = ws.GetHosts(login);
            var host  = (from h in hosts.Hosts where h.host == host_name select h).FirstOrDefault();
            if (host == null)
            {
                Console.WriteLine("Host '" + host_name + "' not found.");
                return(1);
            }
            var revs = ws.GetRevisions(login, null, lane.lane, limit, 0);
            foreach (var rev in revs.Revisions)
            {
                var watch = new Stopwatch();
                watch.Start();
                var res3 = ws.GetViewLaneData(login, lane.id, null, host.id, null, rev.id, null);
                watch.Stop();
                if (res3.RevisionWork == null)
                {
                    Console.WriteLine("Host/lane pair not found.");
                    return(1);
                }
                DBState state = (DBState)res3.RevisionWork.state;
                string  extra = "";
                if (state == DBState.Executing || state == DBState.Issues)
                {
                    int    nsteps = 0;
                    int    ndone  = 0;
                    string step   = "";
                    foreach (var view in res3.WorkViews)
                    {
                        nsteps++;
                        DBState viewstate = (DBState)view.state;
                        if (viewstate != DBState.NotDone && viewstate != DBState.Executing)
                        {
                            ndone++;
                        }
                        if (viewstate == DBState.Executing)
                        {
                            step = view.command;
                        }
                    }
                    extra = " (" + nsteps + "/" + ndone + (step != "" ? " " + step : "") + ")";
                }
                if (state == DBState.Issues || state == DBState.Failed)
                {
                    string failed = "";
                    foreach (var view in res3.WorkViews)
                    {
                        if ((DBState)view.state == DBState.Failed)
                        {
                            if (failed != "")
                            {
                                failed += " ";
                            }
                            failed += view.command;
                        }
                    }
                    if (failed != "")
                    {
                        extra += " (" + failed + ")";
                    }
                }
                Console.WriteLine("" + rev.revision + " " + rev.author + " " + state + extra);
            }
        }
        else if (command == "help")
        {
            PrintUsage();
        }
        else
        {
            PrintUsage();
            return(1);
        }
        ws.Logout(login);
        return(0);
    }
Пример #27
0
        public static string CreateWebServiceDownloadNamedUrl(int work_id, string filename, WebServiceLogin login, bool redirect)
        {
            string uri = CreatePage("Download.aspx");

            uri += "?";
            uri += "work_id=" + work_id.ToString();
            uri += "&filename=" + System.Web.HttpUtility.UrlEncode(filename);
            if (!redirect)
            {
                uri += "&cookie=" + login.Cookie;
                uri += "&ip4=" + login.Ip4;
                uri += "&user=" + login.User;
            }
            return(uri);
        }
Пример #28
0
        public static string CreateWebServiceDownloadRevisionUrl(int revision_id, bool diff, WebServiceLogin login)
        {
            string uri = CreatePage("Download.aspx");

            uri += "?";
            uri += "cookie=" + login.Cookie;
            uri += "&ip4=" + login.Ip4;
            uri += "&user="******"&revision_id=" + revision_id.ToString();
            uri += "&diff=" + (diff ? "true" : "false");
            return(uri);
        }
Пример #29
0
 public void CreateLogin(string user, string password)
 {
     WebServiceLogin          = new WebServiceLogin();
     WebServiceLogin.User     = user;
     WebServiceLogin.Password = password;
 }
Пример #30
0
        // GET: /Builds/monodevelop
        public ActionResult MonoDevelop()
        {
            WebServices ws = new WebServices ();
            WebServiceLogin login = new WebServiceLogin ();

            FrontPageResponse data = ws.GetFrontPageData2 (login, 10, null, null);

            List<StatusStrip> strips = new List<StatusStrip> ();

            StatusStrip strip_md = new StatusStrip ("MonoDevelop - Trunk");
            AddRowsToStrip (strip_md, "monodevelop", new int[] { 131 }, data);
            strips.Add (strip_md);

            ViewData["PageTitle"] = "MonkeyWrench - MonoDevelop";

            return View ("Index", strips);
        }
Пример #31
0
        private void DownloadWorkFile(int workfile_id, string md5)
        {
            DBWorkFileView view = null;
            DBFile         file = null;
            string         filename;
            string         mime;
            string         compressed_mime;

            using (DB db = new DB()) {
                WebServiceLogin login = Authentication.CreateLogin(Request);

                filename = Request ["filename"];

                if (!string.IsNullOrEmpty(md5))                    // md5 lookup needs admin rights
                {
                    Authentication.VerifyUserInRole(Context, db, login, Roles.Administrator, false);
                    file = DBFile_Extensions.Find(db, md5);

                    if (file == null)
                    {
                        throw new HttpException(404, "Could not find the file.");
                    }

                    mime            = file.mime;
                    filename        = file.filename;
                    compressed_mime = file.compressed_mime;
                }
                else
                {
                    view = DBWorkFileView_Extensions.Find(db, workfile_id);

                    if (view == null)
                    {
                        throw new HttpException(404, "Could not find the file.");
                    }

                    if (view.@internal)                     // internal files need admin rights
                    {
                        Authentication.VerifyUserInRole(Context, db, login, Roles.Administrator, false);
                    }
                    else
                    {
                        Authentication.VerifyAnonymousAccess(Context, db, login);
                    }

                    if (!string.IsNullOrEmpty(filename))
                    {
                        file = DBWork_Extensions.GetFile(db, view.work_id, filename, false);
                        if (file == null)
                        {
                            throw new HttpException(404, string.Format("Could not find the filename '{0}'", filename));
                        }

                        mime            = file.mime;
                        compressed_mime = file.compressed_mime;
                        md5             = file.md5;

                        view = null;
                    }
                    else
                    {
                        mime            = view.mime;
                        filename        = view.filename;
                        compressed_mime = view.compressed_mime;
                    }
                }

                Response.ContentType = mime;
                Response.AppendHeader("Content-Disposition", "filename=\"" + Path.GetFileName(filename) + "\"");

                // any access rights verified, serve the file

                if (view != null)
                {
                    if (view.file_file_id == null)
                    {
                        DownloadMd5(view.md5);
                    }
                    else
                    {
                        using (Stream str = db.Download(view)) {
                            DownloadStream(str, compressed_mime);
                        }
                    }
                }
                else
                {
                    DownloadFile(db, file);
                }
            }
        }
Пример #32
0
        // GET: /Builds/monoextended
        public ActionResult MonoExtended()
        {
            int[] trunk_dist_rows = new int[] { 14, 110, 111, 128, 129 };
            int[] trunk_rows = new int[] { 34, 35, 36, 37, 31, 41, 84 };
            int[] trunk_rpm_rows = new int[] { 39 };
            int[] trunk_40_rows = new int[] { 58 };
            int[] trunk_minimal_rows = new int[] { 38 };
            int[] mono_26_rows = new int[] { 75, 99, 98, 100, 116, 163, 164, 122, 125, 126 };
            int[] mono_26_rpm_rows = new int[] { 112 };
            int[] mono_243_rows = new int[] { 102, 94, 101, 96, 123, 119, 120, 97, 115, 124, 127 };

            WebServices ws = new WebServices ();
            WebServiceLogin login = new WebServiceLogin ();

            FrontPageResponse data = ws.GetFrontPageData2 (login, 10, null, null);

            List<StatusStrip> strips = new List<StatusStrip> ();

            StatusStrip strip_trunk_dist = new StatusStrip ("Mono - Trunk - Dist");
            AddRowsToStrip (strip_trunk_dist, null, trunk_dist_rows, data);

            StatusStrip strip_trunk = new StatusStrip ("Mono - Trunk");
            AddRowsToStrip (strip_trunk, null, trunk_rows, data);

            StatusStrip strip_rpm = new StatusStrip ("Mono - Trunk - rpm");
            AddRowsToStrip (strip_rpm, null, trunk_rpm_rows, data);

            StatusStrip strip_40 = new StatusStrip ("Mono - Trunk - 4.0");
            AddRowsToStrip (strip_40, null, trunk_40_rows, data);

            StatusStrip strip_trunk_min = new StatusStrip ("Mono - Trunk - Minimal");
            AddRowsToStrip (strip_trunk_min, null, trunk_minimal_rows, data);

            StatusStrip strip_26 = new StatusStrip ("Mono - 2.6");
            AddRowsToStrip (strip_26, null, mono_26_rows, data);

            StatusStrip strip_rpm_26 = new StatusStrip ("Mono - 2.6 - rpm");
            AddRowsToStrip (strip_rpm_26, null, mono_26_rpm_rows, data);

            StatusStrip strip24 = new StatusStrip ("Mono - 2.4.3");
            AddRowsToStrip (strip24, null, mono_243_rows, data);

            strips.Add (strip_trunk_dist);
            strips.Add (strip_trunk);
            strips.Add (strip_rpm);
            strips.Add (strip_40);
            strips.Add (strip_26);
            strips.Add (strip_rpm_26);
            strips.Add (strip24);

            ViewData["PageTitle"] = "MonkeyWrench - Mono Extended Build Overview";

            return View ("Index", strips);
        }
Пример #33
0
        // GET: /Builds/other
        public ActionResult Other()
        {
            WebServices ws = new WebServices ();
            WebServiceLogin login = new WebServiceLogin ();

            FrontPageResponse data = ws.GetFrontPageData2 (login, 10, null, null);

            List<StatusStrip> strips = new List<StatusStrip> ();

            StatusStrip strip_md = new StatusStrip ();
            strip_md.Name = "MonoDevelop - 2.2 - Dist";
            strip_md.Rows.Add (MonkeyWrenchHelper.GetRow (49, data, "dist"));
            strip_md.Rows.Add (MonkeyWrenchHelper.GetRow (50, data, "database-dist"));
            strip_md.Rows.Add (MonkeyWrenchHelper.GetRow (51, data, "boo-dist"));
            strip_md.Rows.Add (MonkeyWrenchHelper.GetRow (52, data, "java-dist"));
            strip_md.Rows.Add (MonkeyWrenchHelper.GetRow (53, data, "vala-dist"));
            strip_md.Rows.Add (MonkeyWrenchHelper.GetRow (54, data, "debugger-gdb-dist"));
            strip_md.Rows.Add (MonkeyWrenchHelper.GetRow (55, data, "debugger-mdb-dist"));
            strip_md.Rows.Add (MonkeyWrenchHelper.GetRow (56, data, "python-dist"));

            StatusStrip strip_tools = new StatusStrip ();
            strip_tools.Name = "Tools - Trunk";
            strip_tools.Rows.Add (MonkeyWrenchHelper.GetRow (10, data, "libgdiplus - dist"));
            strip_tools.Rows.Add (MonkeyWrenchHelper.GetRow (43, data, "libgdiplus - check"));
            strip_tools.Rows.Add (MonkeyWrenchHelper.GetRow (44, data, "mono-tools - dist"));
            strip_tools.Rows.Add (MonkeyWrenchHelper.GetRow (47, data, "xsp - dist"));
            strip_tools.Rows.Add (MonkeyWrenchHelper.GetRow (48, data, "debugger - dist"));

            StatusStrip strip_tools_26 = new StatusStrip ();
            strip_tools_26.Name = "Tools - 2.6";
            strip_tools_26.Rows.Add (MonkeyWrenchHelper.GetRow (76, data, "libgdiplus - dist"));
            strip_tools_26.Rows.Add (MonkeyWrenchHelper.GetRow (78, data, "mono-tools - dist"));
            strip_tools_26.Rows.Add (MonkeyWrenchHelper.GetRow (79, data, "xsp - dist"));
            strip_tools_26.Rows.Add (MonkeyWrenchHelper.GetRow (77, data, "debugger - dist"));
            strip_tools_26.Rows.Add (MonkeyWrenchHelper.GetRow (80, data, "mono-basic - dist"));
            strip_tools_26.Rows.Add (MonkeyWrenchHelper.GetRow (81, data, "mod_mono - dist"));
            strip_tools_26.Rows.Add (MonkeyWrenchHelper.GetRow (82, data, "gluezilla - dist"));

            StatusStrip strip_tools_24 = new StatusStrip ();
            strip_tools_24.Name = "Tools - 2.4.3";
            strip_tools_24.Rows.Add (MonkeyWrenchHelper.GetRow (108, data, "libgdiplus - dist"));
            strip_tools_24.Rows.Add (MonkeyWrenchHelper.GetRow (106, data, "mono-tools - dist"));
            strip_tools_24.Rows.Add (MonkeyWrenchHelper.GetRow (107, data, "xsp - dist"));
            strip_tools_24.Rows.Add (MonkeyWrenchHelper.GetRow (103, data, "debugger - dist"));
            strip_tools_24.Rows.Add (MonkeyWrenchHelper.GetRow (109, data, "mono-basic - dist"));
            strip_tools_24.Rows.Add (MonkeyWrenchHelper.GetRow (105, data, "mod_mono - dist"));
            strip_tools_24.Rows.Add (MonkeyWrenchHelper.GetRow (104, data, "gluezilla - dist"));

            StatusStrip strip_mw = new StatusStrip ();
            strip_mw.Name = "MonkeyWrench";
            strip_mw.Rows.Add (MonkeyWrenchHelper.GetRow (57, data));

            strips.Add (strip_md);
            strips.Add (strip_tools);
            strips.Add (strip_tools_26);
            strips.Add (strip_tools_24);
            strips.Add (strip_mw);

            ViewData["PageTitle"] = "MonkeyWrench - Other Projects Build Overview";

            return View ("Index", strips);
        }
Пример #34
0
        public ActionResult RevisionDetails(string project, string platform, string revision)
        {
            int lane_id;
            int host_id;
            int revision_id;

            if (!FindHostAndLane (project, platform, out host_id, out lane_id))
                return View ("Error");

            WebServices ws = new WebServices ();
            WebServiceLogin login = new WebServiceLogin ();

            var rev = ws.FindRevisionForLane (login, null, revision, lane_id, null);
            revision_id = rev.Revision.id;

            GetViewLaneDataResponse data = ws.GetViewLaneData (login, lane_id, null, host_id, null, revision_id, null);

            Commit commit = new Commit ();

            commit.CompletionStatus = data.RevisionWork.state;
            commit.Revision = data.Revision.revision;
            commit.Author = data.Revision.author;
            commit.CommitTime = data.Revision.date;
            commit.Lane = data.Lane.lane;
            commit.Host = data.Host.host;
            commit.Builder = data.WorkHost == null ? "" : data.WorkHost.host;
            commit.BuildDuration = TimeSpan.Zero;
            commit.CommitLog = "";
            commit.Email = SvnGravatars.Get (commit.Author);
            commit.ProjectLinkName = project;

            // Download the commit log to add
            string url = string.Format ("http://build.mono-project.com/GetRevisionLog.aspx?id={0}", data.Revision.id);

            WebClient wc = new WebClient ();
            string content = wc.DownloadString (url);

            Regex reg = new Regex (@"\<pre\ id\=\""ctl00_content_log\""\>(?<data>(?:.|\n)*?)\<\/pre\>", RegexOptions.Multiline);
            Match m = reg.Match (content);
            commit.CommitLog = m.Groups["data"].Value.Trim ();

            // Build the list of steps
            BuildStepList bsl = new BuildStepList ();

            string history_url = @"http://build.mono-project.com/ViewWorkTable.aspx?lane_id={0}&host_id={1}&command_id={2}";
            string log_url = @"http://build.mono-project.com/GetFile.aspx?id={0}";

            DateTime start_time = DateTime.MinValue;

            for (int j = 0; j < data.WorkViews.Length; j++) {
                var item = data.WorkViews[j];
                var log = data.WorkFileViews[j];

                if (j == 0)
                    start_time = item.starttime;

                BuildStepListItem i = new BuildStepListItem ();

                i.BuildStepID = item.id;
                i.ElapsedTime = item.endtime.Subtract (item.starttime);
                i.HistoryUrl = string.Format (history_url, lane_id, host_id, item.command_id);
                i.Name = item.command;
                i.Results = item.summary;
                i.CompletionStatus = item.state;

                if (log != null && log.Length > 0)
                    i.LogUrl = string.Format (log_url, log[0].id);

                bsl.Items.Add (i);
            }

            if (data.RevisionWork.completed)
                commit.BuildDuration = data.RevisionWork.endtime.Subtract (start_time);

            //ws.getre
            ViewData["commit"] = commit;
            ViewData["steps"] = bsl;
            ViewData["PageTitle"] = string.Format ("MonkeyWrench - Revision {0} - Host {1}", commit.Revision, commit.Host);

            return View ("RevisionDetails");
        }
Пример #35
0
        // GET: /Builds/Official
        public ActionResult Index()
        {
            int[] trunk_rows = new int[] { 14, 41, 31, 110, 128, 129 };
            int[] mono26_rows = new int[] { 75, 100, 98, 122, 163, 164 };
            int[] mono24_rows = new int[] { 94, 101, 96, 123, 119, 120 };

            WebServices ws = new WebServices ();
            WebServiceLogin login = new WebServiceLogin ();

            DateTime start = DateTime.Now;
            FrontPageResponse data = ws.GetFrontPageData2 (login, 10, null, null);
            TimeSpan data_elapsed = DateTime.Now - start;

            List<StatusStrip> strips = new List<StatusStrip> ();

            StatusStrip strip = new StatusStrip ("Mono - Trunk");
            AddRowsToStrip (strip, "mono", trunk_rows, data);

            StatusStrip strip26 = new StatusStrip ("Mono - 2.6 Branch");
            AddRowsToStrip (strip26, "mono26", mono26_rows, data);

            StatusStrip strip24 = new StatusStrip ("Mono - 2.4 Branch");
            AddRowsToStrip (strip24, "mono24", mono24_rows, data);

            strips.Add (strip);
            strips.Add (strip26);
            strips.Add (strip24);

            // This adds the MSVC build to the page.
            // Disabled because the MSVC build doesn't support Git
            //start = DateTime.Now;
            //try {
            //        MonkeyWrench.Public.Public ws2 = new MvcWrench.MonkeyWrench.Public.Public ();
            //        var msvc = ws2.GetRecentData ("msvc");

            //        strip.Rows.Add (MonkeyWrenchHelper.GetRow (msvc));
            //        //strip.Rows.Insert (0, MonkeyWrenchHelper.GetHeaderRow (msvc));
            //} catch {
            //        // Carry on even if this fails
            //}
            //TimeSpan remote_elapsed = DateTime.Now - start;
            //ViewData["MsvcElapsed"] = remote_elapsed;

            ViewData["PageTitle"] = "MonkeyWrench - Mono Build Overview";
            ViewData["MonkeyWrenchElapsed"] = data_elapsed;

            return View ("Index", strips);
        }