Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            intProfile = Int32.Parse(Request.Cookies["profileid"].Value);
            Workstations     oWorkstation      = new Workstations(0, dsn);
            OnDemand         oOnDemand         = new OnDemand(0, dsn);
            Forecast         oForecast         = new Forecast(0, dsn);
            ModelsProperties oModelsProperties = new ModelsProperties(0, dsn);

            if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
            {
                Functions oFunction      = new Functions(0, dsn, intEnvironment);
                int       intWorkstation = Int32.Parse(oFunction.decryptQueryString(Request.QueryString["id"]));
                int       intType        = oModelsProperties.GetType(intModelVirtual);
                DataSet   dsSteps        = oOnDemand.GetSteps(intType, 1);
                DataSet   ds             = oWorkstation.GetVirtual(intWorkstation);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    int          intAnswer   = Int32.Parse(ds.Tables[0].Rows[0]["answerid"].ToString());
                    int          intRemote   = Int32.Parse(ds.Tables[0].Rows[0]["remoteid"].ToString());
                    int          intCurrent  = Int32.Parse(ds.Tables[0].Rows[0]["step"].ToString());
                    Workstations workstation = new Workstations(0, dsnRemote);
                    DataSet      dsResult    = workstation.GetWorkstationVirtualRemoteStatus(intRemote);
                    if (dsResult.Tables[0].Rows.Count > 0)
                    {
                        int intStep = Int32.Parse(dsResult.Tables[0].Rows[0]["step"].ToString());
                        int intID   = Int32.Parse(dsResult.Tables[0].Rows[0]["id"].ToString());
                        if (intStep == 1)
                        {
                            oWorkstation.AssignHost(intWorkstation, dsnRemote, dsnAsset, intEnvironment, dsnZeus);
                            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "completed", "<script type=\"text/javascript\">window.onload = new Function(\"redirectWait();\");<" + "/" + "script>");
                        }
                        else if (intCurrent < intStep)
                        {
                            oOnDemand.UpdateStepDoneWorkstation(intWorkstation, intCurrent, oOnDemand.GetStep(intStep, "done"), 0, false, false);
                            oWorkstation.NextVirtualStep(intWorkstation);
                            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "completed", "<script type=\"text/javascript\">window.onload = new Function(\"redirect();\");<" + "/" + "script>");
                        }
                        else if (intCurrent == dsSteps.Tables[0].Rows.Count)
                        {
                            oWorkstation.NextVirtualStep(intWorkstation);
                            //SqlHelper.ExecuteNonQuery(dsnRemote, CommandType.Text, "UPDATE cv_virtual_workstations SET deleted = 1 WHERE id = " + intID.ToString() + " AND deleted = 0");
                            oForecast.UpdateAnswerCompleted(intAnswer);
                            oWorkstation.UpdateVirtualCompleted(intWorkstation);
                            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "completed", "<script type=\"text/javascript\">window.onload = new Function(\"redirect();\");<" + "/" + "script>");
                        }
                    }
                }
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "completed", "<script type=\"text/javascript\">window.onload = new Function(\"redirectWait();\");<" + "/" + "script>");
            }
        }
Пример #2
0
        private void Load(int _typeid, TreeNode oParent)
        {
            DataSet ds       = oOnDemand.GetSteps(_typeid, 0);
            int     intCount = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                intCount++;
                TreeNode oNode = new TreeNode();
                oNode.Text         = intCount.ToString() + ") " + dr["name"].ToString();
                oNode.ToolTip      = intCount.ToString() + ") " + dr["name"].ToString();
                oNode.SelectAction = TreeNodeSelectAction.Expand;
                oNode.NavigateUrl  = Request.Path + "?id=" + dr["id"].ToString();
                oParent.ChildNodes.Add(oNode);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            OnDemand         oOnDemand         = new OnDemand(0, dsn);
            Forecast         oForecast         = new Forecast(0, dsn);
            Workstations     oWorkstation      = new Workstations(0, dsn);
            Models           oModel            = new Models(0, dsn);
            Users            oUser             = new Users(0, dsn);
            ModelsProperties oModelsProperties = new ModelsProperties(0, dsn);
            Functions        oFunction         = new Functions(0, dsn, intEnvironment);
            Asset            oAsset            = new Asset(0, dsnAsset);
            Tokens           oToken            = new Tokens(0, dsn);
            string           strOnLoad         = "";
            string           strError          = "";

            if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
            {
                int     intWorkstation = Int32.Parse(oFunction.decryptQueryString(Request.QueryString["id"]));
                DataSet ds             = oWorkstation.GetVirtual(intWorkstation);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    int intAnswer = Int32.Parse(ds.Tables[0].Rows[0]["answerid"].ToString());
                    int intAsset  = Int32.Parse(ds.Tables[0].Rows[0]["assetid"].ToString());

                    if (intAsset > 0 && oAsset.Get(intAsset, "name") != "")
                    {
                        strName = oAsset.Get(intAsset, "name");
                    }
                    else
                    {
                        strName = "Device " + Request.QueryString["c"];
                    }
                    int intModel = oForecast.GetModelAsset(intAnswer);
                    if (intModel == 0)
                    {
                        intModel = oForecast.GetModel(intAnswer);
                    }
                    intModel = Int32.Parse(oModelsProperties.Get(intModel, "modelid"));
                    int intType             = oModel.GetType(intModel);
                    int intCurrent          = Int32.Parse(ds.Tables[0].Rows[0]["step"].ToString());
                    int intCurrentWithError = oWorkstation.GetVirtualStep(intWorkstation);
                    strPreviewName = strName;
                    DataSet dsSteps = oOnDemand.GetSteps(intType, 1);
                    if (dsSteps.Tables[0].Rows.Count >= intCurrent)
                    {
                        int     intNewStep = Int32.Parse(dsSteps.Tables[0].Rows[intCurrent - 1]["id"].ToString());
                        DataSet dsStep     = oOnDemand.GetStep(intNewStep);
                        if (dsStep.Tables[0].Rows.Count > 0)
                        {
                            string strPath = dsStep.Tables[0].Rows[0]["path"].ToString();
                            if (dsStep.Tables[0].Rows[0]["show_build"].ToString() == "1")
                            {
                                chkPreview.Disabled = false;
                                if (!IsPostBack && Request.QueryString["preview"] != null)
                                {
                                    intShowBuild       = 1;
                                    chkPreview.Checked = true;
                                    // Token
                                    strPreviewToken = oToken.Add(strPreviewName, 50);
                                }
                            }
                            else
                            {
                                chkPreview.Disabled = true;
                            }
                            if (strPath != "")
                            {
                                Control oControl = (Control)LoadControl(strPath);
                                PH.Controls.Add(oControl);
                                strOnLoad = "redirectWait();";
                            }
                            else
                            {
                                strOnLoad = "redirectAJAX('" + intWorkstation.ToString() + "','" + intCurrentWithError.ToString() + "');";
                            }
                        }
                    }
                    else
                    {
                        panDone.Visible = true;
                        if (ds.Tables[0].Rows[0]["completed"].ToString() != "")
                        {
                            lblCompleted.Text = DateTime.Parse(ds.Tables[0].Rows[0]["completed"].ToString()).ToString();
                        }
                        else
                        {
                            lblCompleted.Text = DateTime.Now.ToString();
                        }
                    }

                    int           intStep   = 0;
                    StringBuilder sbStep    = new StringBuilder();
                    bool          boolError = false;
                    foreach (DataRow drStep in dsSteps.Tables[0].Rows)
                    {
                        intStep++;
                        string strClass = "cantclose";
                        if (drStep["type"].ToString() == "1")
                        {
                            strClass = "canclose";
                        }
                        if (drStep["type"].ToString() == "-1")
                        {
                            strClass = "default";
                        }
                        DataSet dsResult = oOnDemand.GetStepDoneWorkstation(intWorkstation, intStep);
                        if (intStep < intCurrent)
                        {
                            string strImage   = "<img src=\"/images/check.gif\" border=\"0\" align=\"absmiddle\">";
                            string strDone    = "";
                            string strMessage = "";
                            if (dsResult.Tables[0].Rows.Count > 0)
                            {
                                foreach (DataRow drResult in dsResult.Tables[0].Rows)
                                {
                                    strMessage += drResult["result"].ToString();
                                }
                                if (dsResult.Tables[0].Rows[0]["finished"].ToString() != "")
                                {
                                    strDone = "&nbsp;&nbsp;(" + DateTime.Parse(dsResult.Tables[0].Rows[0]["finished"].ToString()).ToString() + ")";
                                }
                            }
                            sbStep.Append("<tr><td>");
                            sbStep.Append(strImage);
                            sbStep.Append("</td><td nowrap><a href=\"javascript:void(0);\" onclick=\"ShowHideResult('divResult_");
                            sbStep.Append(intAnswer.ToString());
                            sbStep.Append("_");
                            sbStep.Append(intStep.ToString());
                            sbStep.Append("');\">");
                            sbStep.Append(drStep["title"].ToString());
                            sbStep.Append("</a>");
                            sbStep.Append(strDone);
                            sbStep.Append("</td></tr>");
                            sbStep.Append("<tr id=\"divResult_");
                            sbStep.Append(intAnswer.ToString());
                            sbStep.Append("_");
                            sbStep.Append(intStep.ToString());
                            sbStep.Append("\" style=\"display:none\"><td></td><td>");
                            sbStep.Append(strMessage == "" ? "No information" : strMessage);
                            sbStep.Append("</td></tr>");
                        }
                        else if (intStep == intCurrent)
                        {
                            strError = "";
                            if (dsResult.Tables[0].Rows.Count > 0)
                            {
                                if (dsResult.Tables[0].Rows[0]["error"].ToString() == "1")
                                {
                                    boolError = true;
                                    sbStep.Append("<tr><td><img src=\"/images/error.gif\" border=\"0\" align=\"absmiddle\"></td><td class=\"");
                                    sbStep.Append(strClass);
                                    sbStep.Append("\" nowrap><a href=\"javascript:void(0);\" onclick=\"ShowHideResult('divResult_");
                                    sbStep.Append(intAnswer.ToString());
                                    sbStep.Append("_");
                                    sbStep.Append(intStep.ToString());
                                    sbStep.Append("');\">");
                                    sbStep.Append(drStep["title"].ToString());
                                    sbStep.Append("</a></td></tr>");
                                    sbStep.Append("<tr id=\"divResult_");
                                    sbStep.Append(intAnswer.ToString());
                                    sbStep.Append("_");
                                    sbStep.Append(intStep.ToString());
                                    sbStep.Append("\" style=\"display:none\"><td></td><td>");
                                    strError = dsResult.Tables[0].Rows[0]["result"].ToString();
                                    if (strError.Contains("~") == true)
                                    {
                                        strError = strError.Substring(0, strError.IndexOf("~"));
                                    }
                                    sbStep.Append(strError);
                                    DataSet dsError  = oWorkstation.GetVirtualError(intWorkstation, intStep);
                                    string  incident = "";
                                    int     assigned = 0;
                                    if (dsError.Tables[0].Rows.Count > 0)
                                    {
                                        incident = dsError.Tables[0].Rows[0]["incident"].ToString();
                                        Int32.TryParse(dsError.Tables[0].Rows[0]["assigned"].ToString(), out assigned);
                                        if (string.IsNullOrEmpty(incident) == false)
                                        {
                                            sbStep.Append("<br/><br/>Tracking # " + incident);
                                            bool    IncidentFound = false;
                                            DataSet dsKey         = oFunction.GetSetupValuesByKey("INCIDENTS");
                                            if (dsKey.Tables[0].Rows.Count > 0)
                                            {
                                                string       incidents   = dsKey.Tables[0].Rows[0]["Value"].ToString();
                                                StreamReader theReader   = new StreamReader(incidents);
                                                string       theContents = theReader.ReadToEnd();
                                                string[]     theLines    = theContents.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                                                foreach (string theLine in theLines)
                                                {
                                                    if (theLine.Contains(incident))
                                                    {
                                                        IncidentFound = true;
                                                        string[] theFields = theLine.Split(new char[] { ',' }, StringSplitOptions.None);
                                                        string   person    = theFields[5].Replace("\"", "");
                                                        if (String.IsNullOrEmpty(person) == false)
                                                        {
                                                            sbStep.Append("<br/>Assigned To: " + person);
                                                        }
                                                        string group = theFields[4].Replace("\"", "");
                                                        if (String.IsNullOrEmpty(group) == false)
                                                        {
                                                            sbStep.Append("<br/>Group: " + group);
                                                        }
                                                        break;
                                                    }
                                                }
                                            }
                                            if (IncidentFound == false)
                                            {
                                                if (assigned > 0)
                                                {
                                                    sbStep.Append("<br/>Assigned To: " + oUser.GetFullNameWithLanID(assigned));
                                                }
                                            }
                                        }
                                    }
                                    if (strError != "")
                                    {
                                        sbStep.Append("<br/><br/><a class='build_error' href=\"javascript:void(0);\" onclick=\"OpenWindow('PROVISIONING_ERROR', '");
                                        sbStep.Append(oFunction.encryptQueryString(dsResult.Tables[0].Rows[0]["result"].ToString()));
                                        sbStep.Append("');\"><img src='/images/plus.gif' border='0' align='absmiddle'/>&nbsp;For more information about this error, click here</a>");
                                    }
                                    sbStep.Append("</td></tr>");
                                }
                            }
                            if (boolError == false)
                            {
                                if (drStep["interact_path"].ToString() == "")
                                {
                                    sbStep.Append("<tr><td><img src=\"/images/green_arrow.gif\" border=\"0\" align=\"absmiddle\"></td><td class=\"");
                                    sbStep.Append(strClass);
                                    sbStep.Append("\" nowrap><b>");
                                    sbStep.Append(drStep["title"].ToString());
                                    sbStep.Append("</b></td></tr>");
                                }
                                else
                                {
                                    sbStep.Append("<tr><td><img src=\"/images/alert.gif\" border=\"0\" align=\"absmiddle\"></td><td class=\"");
                                    sbStep.Append(strClass);
                                    sbStep.Append("\" nowrap><b>");
                                    sbStep.Append(drStep["title"].ToString());
                                    sbStep.Append("</b></td></tr>");
                                    sbStep.Append("<tr><td></td><td><input type=\"button\" onclick=\"OpenWindow('NEW_WINDOW','");
                                    sbStep.Append(drStep["interact_path"].ToString());
                                    sbStep.Append("?id=");
                                    sbStep.Append(intWorkstation.ToString());
                                    sbStep.Append("');\" value=\"Click Here\" class=\"default\" style=\"width:100px\"></td></tr>");
                                }
                            }
                        }
                        else if (intStep > intCurrent)
                        {
                            sbStep.Append("<tr><td></td><td class=\"");
                            sbStep.Append(strClass);
                            sbStep.Append("\">");
                            sbStep.Append(drStep["title"].ToString());
                            sbStep.Append("</td></tr>");
                        }
                    }
                    sbStep.Insert(0, "<p><table border=\"0\" cellpadding=\"4\" cellspacing=\"3\">");
                    sbStep.Append("</table></p>");
                    strResult += sbStep.ToString();

                    //DateTime datSubmitted = DateTime.Parse(ds.Tables[0].Rows[0]["created"].ToString());
                    //lblDate.Text = datSubmitted.ToString();
                    //Holidays oHoliday = new Holidays(0, dsn);
                    //lblDelivered.Text = oHoliday.GetDays(10.00, datSubmitted).ToString();
                }
            }
            else
            {
                Response.Write("Invalid Configuration - validate host configuration");
            }

            if (strOnLoad != "")
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "start_count", "<script type=\"text/javascript\">window.onload = new Function(\"" + strOnLoad + "\");" + (strError == "" ? "" : "LoadError('" + strError.Replace("'", "") + "');") + "<" + "/" + "script>");
            }
        }
Пример #4
0
        protected void btnGo_Click(Object Sender, EventArgs e)
        {
            Design   oDesign   = new Design(0, dsn);
            Log      oLog      = new Log(0, dsn);
            Forecast oForecast = new Forecast(0, dsn);
            Users    oUser     = new Users(0, dsn);
            int      intID     = Int32.Parse(txtID.Text);
            DataSet  dsDesign  = oDesign.Get(intID);

            if (dsDesign.Tables[0].Rows.Count > 0)
            {
                Int32.TryParse(dsDesign.Tables[0].Rows[0]["answerid"].ToString(), out intID);
            }
            if (oForecast.GetAnswer(intID).Tables[0].Rows.Count > 0)
            {
                ResourceRequest  oResourceRequest  = new ResourceRequest(0, dsn);
                int              intForecast       = Int32.Parse(oForecast.GetAnswer(intID, "forecastid"));
                int              intRequestExecute = oForecast.GetRequestID(intID, true);
                int              intRequest        = Int32.Parse(oForecast.Get(intForecast, "requestid"));
                Requests         oRequest          = new Requests(0, dsn);
                ServiceRequests  oServiceRequest   = new ServiceRequests(0, dsn);
                int              intProject        = oRequest.GetProjectNumber(intRequest);
                Variables        oVariable         = new Variables(intEnvironment);
                Functions        oFunction         = new Functions(0, dsn, intEnvironment);
                Projects         oProject          = new Projects(0, dsn);
                Pages            oPage             = new Pages(0, dsn);
                Servers          oServer           = new Servers(0, dsn);
                Cluster          oCluster          = new Cluster(0, dsn);
                ServerName       oServerName       = new ServerName(0, dsn);
                Asset            oAsset            = new Asset(0, dsnAsset);
                IPAddresses      oIPAddresses      = new IPAddresses(intProfile, dsnIP, dsn);
                OnDemand         oOnDemand         = new OnDemand(0, dsn);
                ModelsProperties oModelsProperties = new ModelsProperties(0, dsn);
                Types            oType             = new Types(0, dsn);
                Storage          oStorage          = new Storage(0, dsn);
                OnDemandTasks    oOnDemandTasks    = new OnDemandTasks(0, dsn);
                VMWare           oVMWare           = new VMWare(0, dsn);
                PNCTasks         oPNCTasks         = new PNCTasks(0, dsn);
                Zeus             oZeus             = new Zeus(intProfile, dsnZeus);

                DataSet dsServers = oServer.GetRequests(intRequestExecute, 0);

                if (chkTimes.Checked == true && (chkExitAP.Checked == true || chkConfig.Checked == true || chkUnlock.Checked == true))
                {
                    strError = "You can not and should not reset times and alter the design at the same time.  RESET PROVISIONING TIMES can not be selected with any other selections.";
                }
                else
                {
                    oLog.AddEvent(intID, "", "", "Design " + intID.ToString() + " reset by " + oUser.GetFullNameWithLanID(intProfile), LoggingType.Information);
                    oForecast.AddReset(intID, -999);
                    if (chkTimes.Checked == true)
                    {
                        DateTime datTimes = DateTime.Today;
                        if (DateTime.TryParse(txtTimes.Text, out datTimes) == true)
                        {
                            // Update Design Dates
                            int intExecutedBy = 0;
                            Int32.TryParse(oForecast.GetAnswer(intID, "executed_by"), out intExecutedBy);
                            if (intExecutedBy > 0)
                            {
                                if (chkTimesForecastExecuted.Checked == true)
                                {
                                    oForecast.UpdateAnswerExecuted(intID, datTimes.ToString(), intExecutedBy);
                                }
                                if (chkTimesForecastCompleted.Checked == true)
                                {
                                    oForecast.UpdateAnswerCompleted(intID, datTimes.ToString());
                                }
                                if (chkTimesTasksStart.Checked == true)
                                {
                                    // Reset all pre-production online tasks (including storage, backup, etc...)
                                    DataSet dsTasks = oPNCTasks.GetStepsDesign(intID, 0, 0);
                                    foreach (DataRow drTask in dsTasks.Tables[0].Rows)
                                    {
                                        int intRRID = 0;
                                        if (Int32.TryParse(drTask["id"].ToString(), out intRRID) == true)
                                        {
                                            // Reset the started and completed (if not null)
                                            oOnDemandTasks.UpdateTime(intRRID, datTimes, chkTimesTasksCompleted.Checked);
                                        }
                                    }
                                }
                                DataSet dsAnswer = oServer.GetAnswer(intID);
                                foreach (DataRow drServer in dsAnswer.Tables[0].Rows)
                                {
                                    int     intServer = Int32.Parse(drServer["id"].ToString());
                                    int     intModel  = Int32.Parse(drServer["modelid"].ToString());
                                    int     intType   = oModelsProperties.GetType(intModel);
                                    DataSet dsSteps   = oOnDemand.GetSteps(intType, 1);
                                    // Update Server Dates
                                    if (oServer.Get(intServer, "build_started") != "")
                                    {
                                        if (chkTimesServerStart.Checked == true)
                                        {
                                            oServer.UpdateBuildStarted(intServer, datTimes.ToString(), true);
                                        }
                                        if (chkTimesServerSteps.Checked == true)
                                        {
                                            int intStep = 0;
                                            foreach (DataRow drStep in dsSteps.Tables[0].Rows)
                                            {
                                                intStep++;
                                                oOnDemand.UpdateStepDoneServer(intServer, intStep, datTimes);
                                            }
                                        }
                                    }

                                    if (chkTimesServerComplete.Checked == true)
                                    {
                                        oServer.UpdateBuildCompleted(intServer, datTimes.ToString());
                                    }

                                    if (chkTimesServerReady.Checked == true)
                                    {
                                        oServer.UpdateBuildReady(intServer, datTimes.ToString(), true);
                                    }
                                }
                            }
                            else
                            {
                                strError = "The design has not been executed";
                            }
                        }
                        else
                        {
                            strError = "Invalid DateTime";
                        }
                    }
                    if (chkExitAP.Checked == true)
                    {
                        // Delete the Manual Build Task
                        DataSet dsManual = oOnDemandTasks.GetGenericII(intID);
                        if (dsManual.Tables[0].Rows.Count > 0)
                        {
                            int intRequestID = Int32.Parse(dsManual.Tables[0].Rows[0]["requestid"].ToString());
                            int intItem      = Int32.Parse(dsManual.Tables[0].Rows[0]["itemid"].ToString());
                            int intNumber    = Int32.Parse(dsManual.Tables[0].Rows[0]["number"].ToString());
                            oOnDemandTasks.DeleteGenericII(intID);
                            DataSet dsParent = oResourceRequest.Get(intRequestID, intItem, intNumber);
                            if (dsParent.Tables[0].Rows.Count > 0)
                            {
                                int intRRID = Int32.Parse(dsParent.Tables[0].Rows[0]["parent"].ToString());
                                oResourceRequest.Delete(intRRID);
                                int intRRWID = Int32.Parse(dsParent.Tables[0].Rows[0]["id"].ToString());
                                oResourceRequest.DeleteWorkflow(intRRWID);
                            }
                        }
                        // Reset automated servers
                        foreach (DataRow drServer in dsServers.Tables[0].Rows)
                        {
                            int intServer = Int32.Parse(drServer["id"].ToString());
                            int intAsset  = 0;
                            Int32.TryParse(drServer["assetid"].ToString(), out intAsset);

                            // Clear MDT / Altiris
                            oServer.ClearMDT(intServer, dsnAsset, dsnZeus, intEnvironment);
                            // Clear ZEUS
                            if (intAsset > 0)
                            {
                                oZeus.DeleteBuild(oAsset.Get(intAsset, "serial"));
                            }
                            // Clear Steps
                            oServer.UpdateStep(intServer, 0);
                            oOnDemand.DeleteStepDoneServers(intServer, 1);
                            // Clear Dates
                            oServer.UpdateBuildStarted(intServer, "", true);
                            oServer.UpdateBuildCompleted(intServer, "");
                            oServer.UpdateBuildReady(intServer, "", true);
                            // Clear Errors
                            DataSet dsError = oServer.GetErrors(intServer);
                            foreach (DataRow drError in dsError.Tables[0].Rows)
                            {
                                if (drError["fixed"].ToString() == "")
                                {
                                    oServer.UpdateError(intServer, Int32.Parse(drError["step"].ToString()), 0, 0, true, dsnAsset);
                                }
                            }
                            // Clear VMware
                            oVMWare.DeleteGuest(oServer.GetName(intServer, true));
                            oServiceRequest.Delete(intRequestExecute);

                            if (chkExitAP_Name.Checked == true && drServer["nameid"].ToString() != "")
                            {
                                int intName = Int32.Parse(drServer["nameid"].ToString());
                                oServer.UpdateServerNamed(intServer, 0);
                                oServerName.UpdateFactory(intName, 1);
                            }
                            if (chkExitAP_IP.Checked == true)
                            {
                                oServer.DeleteIP(intServer, 0, 0, 0, 0, dsnIP);
                            }
                            if (chkExitAP_Asset.Checked == true && intAsset > 0)
                            {
                                oServer.DeleteAsset(intServer);
                                oAsset.AddStatus(intAsset, "", (int)AssetStatus.Available, -100, DateTime.Now);
                            }
                        }
                        // Clear the execution and completion dates
                        oForecast.UpdateAnswerExecution(intID, "");
                        oForecast.UpdateAnswerExecuted(intID, "", 0);
                        oForecast.UpdateAnswerCompleted(intID, "");

                        // Clear the new design builder.
                        if (dsDesign.Tables[0].Rows.Count > 0)
                        {
                            int intDesign = Int32.Parse(dsDesign.Tables[0].Rows[0]["id"].ToString());
                            oForecast.DeleteAnswer(intID);
                            foreach (DataRow drServer in dsServers.Tables[0].Rows)
                            {
                                int intServer = Int32.Parse(drServer["id"].ToString());
                                oServer.Delete(intServer);
                            }
                            oDesign.UpdateAnswerId(intDesign, 0);
                            if (chkExitAP_Approvals.Checked == true)
                            {
                                oDesign.DeleteApproverFieldWorkflow(intDesign);
                                oDesign.DeleteApproverGroupWorkflow(intDesign, 0);
                                oDesign.DeleteApproverGroupWorkflow(intDesign, 1);
                                oDesign.DeleteSoftwareComponents(intDesign, true);
                                if (chkExitAP_Submissions.Checked == false)
                                {
                                    // Reset back to original requestor.
                                    oDesign.Approve(intDesign, 0, (oDesign.Get(intDesign, "is_exception") == "1"), intEnvironment, intImplementorDistributedService, intWorkstationPlatform, intImplementorMidrangeService, dsnAsset, dsnIP, dsnServiceEditor, intAssignPage, intResourceRequestApprove, intViewPage);
                                }
                            }
                            if (chkExitAP_Submissions.Checked == true)
                            {
                                oDesign.DeleteSubmitted(intDesign);
                            }
                        }
                    }
                    if (chkConfig.Checked == true)
                    {
                        int     intModel   = oForecast.GetModel(intID);
                        int     intType    = oModelsProperties.GetType(intModel);
                        string  strExecute = oType.Get(intType, "forecast_execution_path");
                        int     intCount   = 0;
                        DataSet dsWizard   = oOnDemand.GetWizardStepsDoneBack(intID);
                        foreach (DataRow drWizard in dsWizard.Tables[0].Rows)
                        {
                            intCount++;
                            if (intCount != dsWizard.Tables[0].Rows.Count)
                            {
                                oOnDemand.DeleteWizardStepDone(intID, Int32.Parse(drWizard["step"].ToString()));
                            }
                        }
                        if (chkConfig_Reset.Checked == true)
                        {
                            oForecast.UpdateAnswer(intID, "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                        }
                        if (chkConfig_Device.Checked == true)
                        {
                            foreach (DataRow drServer in dsServers.Tables[0].Rows)
                            {
                                int intServer  = Int32.Parse(drServer["id"].ToString());
                                int intCluster = Int32.Parse(drServer["clusterid"].ToString());
                                oCluster.Delete(intCluster, intID);
                                oServer.Delete(intServer);
                            }
                        }
                        if (chkConfig_Storage.Checked == true)
                        {
                            oStorage.DeleteLuns(intID);
                        }
                    }
                    if (chkUnlock.Checked == true)
                    {
                        if (chkUnlock_80.Checked == true)
                        {
                            if (oForecast.GetAnswer(intID, "override") == "-1")
                            {
                                // Send Email to iARB stating that they do not have to approve the design
                                string[] strEmail;
                                char[]   strSplit = { ';' };
                                strEmail = strIARB.Split(strSplit);
                                for (int ii = 0; ii < strEmail.Length; ii++)
                                {
                                    if (strEmail[ii].Trim() != "")
                                    {
                                        string strAddress     = strEmail[ii];
                                        string strEMailIdsBCC = oFunction.GetGetEmailAlertsEmailIds("EMAILGRP_DESIGN_BUILDER");
                                        oFunction.SendEmail("Review Board Approval UNLOCKED", strAddress, "", strEMailIdsBCC, "Review Board Approval UNLOCKED", "<p><b>An overridden design has been unlocked and no longer requires your approval.</b><p><p>" + oForecast.GetAnswerBody(intID, intEnvironment, dsnAsset, dsnIP) + "</p>", true, false);
                                    }
                                }
                            }
                            oForecast.AddAnswerUnlock(intID, 0, "Reset by administrator at client's request");
                            oForecast.UpdateAnswerConfidence(intID, intConfidenceUnlock);
                        }
                        oForecast.DeleteReset(intID);
                        oForecast.AddReset(intID, intRequestExecute);
                        oForecast.UpdateAnswer(intID, 0);
                        DataSet dsPending = oOnDemandTasks.GetPending(intID);
                        if (dsPending.Tables[0].Rows.Count > 0)
                        {
                            int intResourceWorkflow = Int32.Parse(dsPending.Tables[0].Rows[0]["resourceid"].ToString());
                            int intResourceParent   = oResourceRequest.GetWorkflowParent(intResourceWorkflow);
                            int intImplementor      = Int32.Parse(oResourceRequest.GetWorkflow(intResourceWorkflow, "userid"));
                            oResourceRequest.UpdateItemAndService(intResourceParent, -1, -1);
                            oResourceRequest.UpdateWorkflowName(intResourceWorkflow, "Auto-Provisioning Task [Reset]", 0);
                            oOnDemandTasks.DeleteAll(intID);
                            if (intImplementor > 0)
                            {
                                string strDefault     = oUser.GetApplicationUrl(intImplementor, intViewPage);
                                string strSpacerRow   = "<tr><td colspan=\"3\"><img src=\"" + oVariable.ImageURL() + "/images/spacer.gif\" border=\"0\" width=\"1\" height=\"7\" /></td></tr>";
                                string strEMailIdsBCC = oFunction.GetGetEmailAlertsEmailIds("EMAILGRP_DESIGN_BUILDER");
                                if (strDefault == "")
                                {
                                    oFunction.SendEmail("RESET: ClearView Auto-Provisioning Reset", oUser.GetName(intImplementor), "", strEMailIdsBCC, "RESET: ClearView Auto-Provisioning Reset", "<p><b>An auto-provisioning request has been reset. This request no longer requires immediate attention.</b><p><p>" + oForecast.GetAnswerBody(intID, intEnvironment, dsnAsset, dsnIP) + "</p>", true, false);
                                }
                                else
                                {
                                    oFunction.SendEmail("RESET: ClearView Auto-Provisioning Reset", oUser.GetName(intImplementor), "", strEMailIdsBCC, "RESET: ClearView Auto-Provisioning Reset", "<p><b>An auto-provisioning request has been reset. This request no longer requires immediate attention.</b><p><p>" + oForecast.GetAnswerBody(intID, intEnvironment, dsnAsset, dsnIP) + "</p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(intViewPage) + "?pid=" + intProject.ToString() + "\" target=\"_blank\">Click here to review this project.</a></p>", true, false);
                                }
                            }
                        }
                    }
                }

                if (strError == "")
                {
                    lblDone.Text = "<img src='/images/bigcheck.gif' border='0' align='absmiddle'/> <b>Finished!</b> ClearView reset the design";
                }
                else
                {
                    lblDone.Text = "<img src='/images/bigerror.gif' border='0' align='absmiddle'/> <b>Error!</b> " + strError;
                }
            }
            else if (dsDesign.Tables[0].Rows.Count > 0)
            {
                int intDesign = Int32.Parse(dsDesign.Tables[0].Rows[0]["id"].ToString());
                oLog.AddEvent(intDesign, "", "", "Design " + intDesign.ToString() + " reset by " + oUser.GetFullNameWithLanID(intProfile), LoggingType.Information);
                oDesign.UpdateAnswerId(intDesign, 0);
                if (chkExitAP_Approvals.Checked == true)
                {
                    oDesign.DeleteApproverFieldWorkflow(intDesign);
                    oDesign.DeleteApproverGroupWorkflow(intDesign, 0);
                    oDesign.DeleteApproverGroupWorkflow(intDesign, 1);
                    oDesign.DeleteSoftwareComponents(intDesign, true);
                    if (chkExitAP_Submissions.Checked == false)
                    {
                        // Reset back to original requestor.
                        oDesign.Approve(intDesign, 0, (oDesign.Get(intDesign, "is_exception") == "1"), intEnvironment, intImplementorDistributedService, intWorkstationPlatform, intImplementorMidrangeService, dsnAsset, dsnIP, dsnServiceEditor, intAssignPage, intResourceRequestApprove, intViewPage);
                    }
                }
                if (chkExitAP_Submissions.Checked == true)
                {
                    oDesign.DeleteSubmitted(intDesign);
                }
                lblDone.Text = "<img src='/images/bigAlert.gif' border='0' align='absmiddle'/> <b>Done!</b> ClearView reset the new design builder";
            }
            else
            {
                lblDone.Text = "<img src='/images/bigerror.gif' border='0' align='absmiddle'/> <b>Error!</b> ClearView could not find the design";
            }
        }
Пример #5
0
        private void LoadList()
        {
            string strBind = "";

            if (lblType.Text == "PLAT")
            {
                ds = oPlatform.Gets(1);
                lstOrder.DataValueField = "platformid";
            }
            if (lblType.Text == "ORG")
            {
                ds = oOrganization.Gets(1);
                lstOrder.DataValueField = "organizationid";
            }
            if (lblType.Text == "COST")
            {
                ds = oCost.Gets(1);
                lstOrder.DataValueField = "costid";
            }
            if (lblType.Text == "AT")
            {
                ds = oUserAt.Gets(1);
                lstOrder.DataValueField = "atid";
            }
            if (lblType.Text == "ITEMS")
            {
                ds = oRequestItem.GetItems(Int32.Parse(lblId.Text), 0, 1);
                lstOrder.DataValueField = "itemid";
            }
            if (lblType.Text == "SERVICEDETAIL")
            {
                ds = oServiceDetail.Gets(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SERVICES")
            {
                int intFolder = Int32.Parse(oService.GetFolders(Int32.Parse(lblId.Text), "folderid"));
                ds = oService.Gets(intFolder, 1, 1, 1, 0);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SERVICE_FOLDERS")
            {
                ds = oService.GetFolders(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "REPORTS")
            {
                ds = oReport.Gets(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "reportid";
                strBind = "title";
            }
            if (lblType.Text == "A_SITE")
            {
                ds = oSites.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "A_TYPE")
            {
                ds = oType.Gets(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "A_MODEL")
            {
                ds = oModel.Gets(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "A_LOCATION_S")
            {
                ds = oDepot.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "A_SHELF")
            {
                ds = oShelf.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "A_RACK")
            {
                ds = oRacks.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "CLASS")
            {
                ds = oClasses.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "A_ROOM")
            {
                ds = oRooms.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "A_FLOOR")
            {
                ds = oFloor.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "ENVIRONMENT")
            {
                ds = oEnvironment.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "S_CODE")
            {
                ds = oSolution.GetCodes(1);
                lstOrder.DataValueField = "id";
                strBind = "code";
            }
            if (lblType.Text == "F_QUESTION")
            {
                ds = oForecast.GetQuestions(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "F_RESPONSE")
            {
                ds = oForecast.GetResponses(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "F_LINE_ITEMS")
            {
                ds = oForecast.GetLineItems(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "CONFIDENCE")
            {
                ds = oConfidence.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "LOCATION_S")
            {
                ds = oLocation.GetStates(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "F_STEPS")
            {
                ds = oForecast.GetSteps(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "F_STEPS_ADD")
            {
                ds = oForecast.GetStepAdditionals(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "FIELD")
            {
                ds = oField.Gets(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
                strBind = "fieldname";
            }
            if (lblType.Text == "DOMAIN_CONTROLLER")
            {
                ds = oDomainController.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "DOMAIN")
            {
                ds = oDomain.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SERVERNAME_A")
            {
                ds = oServerName.GetApplications(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SERVERNAME_SUBA")
            {
                ds = oServerName.GetSubApplications(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SERVERNAME_C")
            {
                ds = oServerName.GetComponents(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "WORKSTATION_C")
            {
                ds = oWorkstation.GetComponents(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "OPERATING_SYSTEM")
            {
                ds = oOperatingSystems.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "OD_W_STEPS")
            {
                ds = oOnDemand.GetWizardSteps(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "OD_STEPS")
            {
                ds = oOnDemand.GetSteps(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SERVICE_PACK")
            {
                ds = oServicePack.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "COMPONENT_SCRIPTS")
            {
                ds = oServerName.GetComponentDetailScripts(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "HOST")
            {
                ds = oHost.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "VIRTUAL_HDD")
            {
                ds = oVirtualHDD.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "VIRTUAL_RAM")
            {
                ds = oVirtualRam.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "RESTART")
            {
                ds = oRestart.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SEGMENT")
            {
                ds = oSegment.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "DOMAIN_SUFFIX")
            {
                ds = oDomain.GetSuffixs(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "DOMAIN_ADMIN_GROUP")
            {
                ds = oDomain.GetAdminGroups(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SERVICE_EDITOR_FIELDS")
            {
                ds = oServiceEditor.GetFields(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "PROJECT_REQUEST_QUESTION")
            {
                ds = oProjectRequest.GetQuestions(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "PROJECT_REQUEST_RESPONSE")
            {
                ds = oProjectRequest.GetResponses(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "PROJECT_REQUEST_CLASS")
            {
                ds = oProjectRequest.GetClasses(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "VMWARE_TEMPLATE")
            {
                ds = oVMWare.GetTemplates(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "ORDER_REPORT_DATASOURCE")
            {
                ds = oReport.GetDataSources(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "ORDER_REPORT_CHARTS")
            {
                ds = oReport.GetCharts(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "PLATFORM_FORM")
            {
                ds = oPlatform.GetForms(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            //if (lblType.Text == "NEW")
            //{
            //    ds = oNew.Gets(1);
            //    lstOrder.DataValueField = "id";
            //    strBind = "title";
            //}
            if (lblType.Text == "WHATSNEW")
            {
                ds = oWhatsNew.Gets(1);
                lstOrder.DataValueField = "id";
                strBind = "title";
            }
            //if (lblType.Text == "RECOVERY_LOCATIONS")
            //{
            //    ds = oRecoveryLocations.Gets(1);
            //    lstOrder.DataValueField = "id";
            //}
            if (lblType.Text == "MAINTENANCE_WINDOW")
            {
                ds = oMaintenanceWindow.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "TSM")
            {
                ds = oTSM.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "TSM_DOMAINS")
            {
                ds = oTSM.GetDomains(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "TSM_SCHEDULES")
            {
                ds = oTSM.GetSchedules(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "DNS")
            {
                ds = oDNS.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SOLARIS_BUILD_NETWORKS")
            {
                ds = oSolaris.GetBuildNetworks(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SOLARIS_BUILD_TYPES")
            {
                ds = oSolaris.GetBuildTypes(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "SOLARIS_INTERFACES")
            {
                ds = oSolaris.GetInterfaces(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "ZEUS_ARRAY_CONFIGS")
            {
                ds = oZeus.GetArrayConfigs(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "ZEUS_BUILD_TYPES")
            {
                ds = oZeus.GetBuildTypes(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "ERROR_TYPES")
            {
                ds = oError.GetTypes(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "ERROR_TYPES_TYPES")
            {
                ds = oError.GetTypeTypes(Int32.Parse(lblId.Text), 1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "D_PHASES")
            {
                ds      = oDesign.GetPhases(1);
                strBind = "title";
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "D_QUESTIONS")
            {
                ds      = oDesign.GetQuestions(Int32.Parse(lblId.Text), 1);
                strBind = "summary";
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "D_RESPONSES")
            {
                ds      = oDesign.GetResponses(Int32.Parse(lblId.Text), 0, 1);
                strBind = "admin";
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "D_MODELS")
            {
                ds = oDesign.GetModels(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "RESILIENCY")
            {
                ds = oResiliency.Gets(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "ENHANCEMENT_MODULES")
            {
                ds = oEnhancement.GetModules(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "OPERATING_SYSTEM_GROUPS")
            {
                ds = oOperatingSystems.GetGroups(1);
                lstOrder.DataValueField = "id";
            }
            if (lblType.Text == "DESIGN_APPROVE_CONDITION")
            {
                ds = oDesign.GetApprovalConditionals(1);
                lstOrder.DataValueField = "id";
            }



            if (strBind == "")
            {
                strBind = "name";
            }
            lstOrder.DataTextField = strBind;
            lstOrder.DataSource    = ds;
            lstOrder.DataBind();
        }