protected void imgDelete_Click(Object Sender, EventArgs e) { int intId = 0; ImageButton button = (ImageButton)Sender; string strFolderTemp = string.Empty; if (button.CommandArgument != "") { intId = Int32.Parse(button.CommandArgument); oCustomized.DeleteDocumentRepository(intId); string strPath = oCustomized.GetDocumentRepository(intId, "path"); if (strHome != null) { strFolderTemp = strPath.Remove(0, strHome.Trim().Length); strFolderTemp = strFolderTemp.Substring(0, strFolderTemp.LastIndexOf("\\")); } if (oCustomized.GetDocumentRepository(intId, "type").ToLower() == "folder") { if (Directory.Exists(strPath) == true) { Directory.Delete(strPath, true); } } else { if (File.Exists(strPath) == true) { File.Delete(strPath); } } WriteLog("Delete file " + strPath); } Response.Redirect(oPage.GetFullLink(intPage) + "?folder=" + strFolderTemp); }
protected void Page_Load(object sender, EventArgs e) { AuthenticateUser(); intProfile = Int32.Parse(Request.Cookies["profileid"].Value); // Response.Redirect("/redirect.aspx?referrer=/frame/document_repository_rename.aspx?id=" + intDocId); oCustomized = new Customized(intProfile, dsn); oIcon = new Icons(intProfile, dsn); if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { intDocId = Int32.Parse(Request.QueryString["id"]); strType = oCustomized.GetDocumentRepository(intDocId, "type"); if (!IsPostBack) { txtName.Text = oCustomized.GetDocumentRepository(intDocId, "name"); if (txtName.Text.EndsWith(strType)) { txtName.Text = txtName.Text.Substring(0, txtName.Text.IndexOf(strType)); } Page.ClientScript.RegisterStartupScript(typeof(Page), "loader", "<script type=\"text/javascript\">document.getElementById('" + txtName.ClientID + "').focus();document.getElementById('" + txtName.ClientID + "').select();<" + "/" + "script>"); } } // Security code strSecurity = oCustomized.GetDocumentRepositorySharesByIds(intDocId, "security"); if (strSecurity == "") { strSecurity = oCustomized.GetDocumentRepository(intDocId, "security"); } strOwner = oCustomized.GetDocumentRepositorySharesByIds(intDocId, "ownerid"); if (strOwner == "") { strOwner = oCustomized.GetDocumentRepository(intDocId, "profileid"); } strPath = oCustomized.GetDocumentRepository(intDocId, "path"); strProfile = oCustomized.GetDocumentRepository(intDocId, "profileid"); strApplication = oCustomized.GetDocumentRepository(intDocId, "applicationid"); btnRename.Attributes.Add("onclick", "return ValidateText('" + txtName.ClientID + "','Please enter a valid name');"); }
protected void Page_Load(object sender, EventArgs e) { AuthenticateUser(); intProfile = Int32.Parse(Request.Cookies["profileid"].Value); oCustomized = new Customized(intProfile, dsn); oIcon = new Icons(intProfile, dsn); oFunction = new Functions(intProfile, dsn, intEnvironment); if (Request.QueryString["docid"] != null && Request.QueryString["docid"] != "") { Int32.TryParse(oFunction.decryptQueryString(Request.QueryString["docid"]), out intDocId); } int intApplication = 0; if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "") { intApplication = Int32.Parse(Request.Cookies["application"].Value); } if (intDocId > 0) { string strSecurity = oCustomized.GetDocumentRepositorySharesByIds(intDocId, "security"); if (strSecurity == "") { strSecurity = oCustomized.GetDocumentRepository(intDocId, "security"); } string strOwner = oCustomized.GetDocumentRepositorySharesByIds(intDocId, "ownerid"); if (strOwner == "") { strOwner = oCustomized.GetDocumentRepository(intDocId, "profileid"); } string strType = oCustomized.GetDocumentRepository(intDocId, "type"); string strPath = oCustomized.GetDocumentRepository(intDocId, "path"); string strName = oCustomized.GetDocumentRepository(intDocId, "name"); string strSize = oCustomized.GetDocumentRepository(intDocId, "size"); int intIsDepartment = Int32.Parse(oCustomized.GetDocumentRepository(intDocId, "department")); int intDepartment = Int32.Parse(oCustomized.GetDocumentRepository(intDocId, "applicationid")); if (strSecurity == "1" || strSecurity == "10" || strOwner == intProfile.ToString() || (strSecurity == "-1" && intIsDepartment == 1 && intDepartment == intApplication) ) { if (strType != "Folder" && new System.IO.FileInfo(strPath).Exists == true) { DataSet ds = oIcon.Get(strType.ToUpper()); if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["content_type"].ToString() != "") { Response.ContentType = ds.Tables[0].Rows[0]["content_type"].ToString(); } else { Response.Redirect(strPath); } //Response.ContentType = "application/octet-stream"; Response.AppendHeader("content-disposition", "inline;filename=" + strName); Response.AppendHeader("content-length", strSize); Response.WriteFile(strPath); Response.Flush(); Response.End(); } } else { Response.Write("<script type=\"text/javascript\">alert('Access Denied (" + strSecurity.ToString() + "." + intIsDepartment.ToString() + "." + strOwner + "." + intProfile.ToString() + "." + intDepartment.ToString() + "." + intApplication.ToString() + ")!');window.close();</script>"); } } else { Response.Write("<script type=\"text/javascript\">alert('Access Denied!');window.close();</script>"); } }
protected void Page_Load(object sender, EventArgs e) { Response.Cookies["loginreferrer"].Value = Request.Path; Response.Cookies["loginreferrer"].Expires = DateTime.Now.AddDays(30); if (Request.Cookies["adminid"] != null && Request.Cookies["adminid"].Value != "") { intProfile = Int32.Parse(Request.Cookies["adminid"].Value); } else { Response.Redirect("/admin/login.aspx"); } oService = new Services(intProfile, dsn); oRequestItem = new RequestItems(intProfile, dsn); oCustomized = new Customized(intProfile, dsn); oFunction = new Functions(intProfile, dsn, intEnvironment); int intApplication = 0; if (Request.QueryString["id"] == null) { if (Request.QueryString["parent"] == null) { LoadServices(0); } else { panAdd.Visible = true; btnDelete.Enabled = false; } } else { panAdd.Visible = true; intID = Int32.Parse(Request.QueryString["id"]); if (intID > 0 && !IsPostBack) { LoadLists(); DataSet ds = oService.Get(intID); hdnId.Value = intID.ToString(); hdnOrderId.Value = Request.QueryString["orderid"]; txtName.Text = ds.Tables[0].Rows[0]["name"].ToString(); txtDescription.Text = ds.Tables[0].Rows[0]["description"].ToString(); int intItem = 0; if (Int32.TryParse(ds.Tables[0].Rows[0]["itemid"].ToString(), out intItem) == true) { lblItem.Text = oRequestItem.GetItemName(intItem); intApplication = oRequestItem.GetItemApplication(intItem); } if (lblItem.Text == "" || intItem == 0) { lblItem.Text = "No Item"; } hdnItem.Value = intItem.ToString(); int intDocument = 0; if (Int32.TryParse(ds.Tables[0].Rows[0]["docid"].ToString(), out intDocument) == true) { lblDocument.Text = oCustomized.GetDocumentRepository(intDocument, "name"); } if (lblDocument.Text == "" || intDocument == 0) { lblDocument.Text = "No Document"; } hdnDocument.Value = intDocument.ToString(); ddlType.SelectedValue = ds.Tables[0].Rows[0]["typeid"].ToString(); chkShow.Checked = (ds.Tables[0].Rows[0]["show"].ToString() == "1"); chkProject.Checked = (ds.Tables[0].Rows[0]["project"].ToString() == "1"); txtHours.Text = ds.Tables[0].Rows[0]["hours"].ToString(); txtSLA.Text = ds.Tables[0].Rows[0]["sla"].ToString(); chkCanAuto.Checked = (ds.Tables[0].Rows[0]["can_automate"].ToString() == "1"); chkStatement.Checked = (ds.Tables[0].Rows[0]["statement"].ToString() == "1"); chkUpload.Checked = (ds.Tables[0].Rows[0]["upload"].ToString() == "1"); chkExpedite.Checked = (ds.Tables[0].Rows[0]["expedite"].ToString() == "1"); txtRRPath.Text = ds.Tables[0].Rows[0]["rr_path"].ToString(); txtWMPath.Text = ds.Tables[0].Rows[0]["wm_path"].ToString(); txtCPPath.Text = ds.Tables[0].Rows[0]["cp_path"].ToString(); txtCAPath.Text = ds.Tables[0].Rows[0]["ca_path"].ToString(); chkRejection.Checked = (ds.Tables[0].Rows[0]["rejection"].ToString() == "1"); chkAutomate.Checked = (ds.Tables[0].Rows[0]["automate"].ToString() == "1"); chkHours.Checked = (ds.Tables[0].Rows[0]["disable_hours"].ToString() == "1"); chkQuantityDevice.Checked = (ds.Tables[0].Rows[0]["quantity_is_device"].ToString() == "1"); chkQuantityMultiple.Checked = (ds.Tables[0].Rows[0]["multiple_quantity"].ToString() == "1"); chkNotifyPC.Checked = (ds.Tables[0].Rows[0]["notify_pc"].ToString() == "1"); chkNotifyClient.Checked = (ds.Tables[0].Rows[0]["notify_client"].ToString() == "1"); chkDisable.Checked = (ds.Tables[0].Rows[0]["disable_customization"].ToString() == "1"); chkTask.Checked = (ds.Tables[0].Rows[0]["tasks"].ToString() == "1"); txtEmail.Text = ds.Tables[0].Rows[0]["email"].ToString(); chkSameTime.Checked = (ds.Tables[0].Rows[0]["sametime"].ToString() == "1"); chkNotifyGreen.Checked = (ds.Tables[0].Rows[0]["notify_green"].ToString() == "1"); chkNotifyYellow.Checked = (ds.Tables[0].Rows[0]["notify_yellow"].ToString() == "1"); chkNotifyRed.Checked = (ds.Tables[0].Rows[0]["notify_red"].ToString() == "1"); chkWorkflow.Checked = (ds.Tables[0].Rows[0]["workflow"].ToString() == "1"); txtWorkflow.Text = ds.Tables[0].Rows[0]["workflow_title"].ToString(); chkRestrictions.Checked = (ds.Tables[0].Rows[0]["is_restricted"].ToString() == "1"); chkTitleOverrride.Checked = (ds.Tables[0].Rows[0]["title_override"].ToString() == "1"); txtTitleName.Text = ds.Tables[0].Rows[0]["title_name"].ToString(); chkNoSlider.Checked = (ds.Tables[0].Rows[0]["no_slider"].ToString() == "1"); chkHideSLA.Checked = (ds.Tables[0].Rows[0]["hide_sla"].ToString() == "1"); chkApproval.Checked = (ds.Tables[0].Rows[0]["approval"].ToString() == "1"); chkManagerApprove.Checked = (ds.Tables[0].Rows[0]["manager_approval"].ToString() == "1"); ddlWorkflowAssignment.SelectedValue = ds.Tables[0].Rows[0]["workflow_userid"].ToString(); txtNotifyComplete.Text = ds.Tables[0].Rows[0]["notify_complete"].ToString(); chkWorkflowConnectable.Checked = (ds.Tables[0].Rows[0]["workflow_connect"].ToString() == "1"); chkWorkflowSameTechnician.Checked = (ds.Tables[0].Rows[0]["same_technician"].ToString() == "1"); chkEnabled.Checked = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1"); btnAdd.Text = "Update"; } } btnOrder.Attributes.Add("onclick", "return OpenWindow('SUPPORTORDER','" + hdnOrderId.ClientID + "','" + hdnOrder.ClientID + "&type=SERVICES" + "',false,400,400);"); btnDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this service?');"); btnItem.Attributes.Add("onclick", "return OpenWindow('ITEMBROWSER','" + hdnItem.ClientID + "','&control=" + hdnItem.ClientID + "&controltext=" + lblItem.ClientID + "',false,400,600);"); btnDocument.Attributes.Add("onclick", "return OpenWindow('DOCUMENTBROWSER','" + hdnDocument.ClientID + "','&control=" + hdnDocument.ClientID + "&controltext=" + lblDocument.ClientID + "&applicationid=" + intApplication.ToString() + "',false,400,600);"); btnImage.Attributes.Add("onclick", "return OpenWindow('IMAGEPATH','','" + txtImage.ClientID + "',false,500,550);"); btnRoles.Attributes.Add("onclick", "return OpenWindow('SERVICEDETAILROLES','" + hdnId.ClientID + "','',false,'500',600);"); btnLocation.Attributes.Add("onclick", "return OpenWindow('SERVICELOCATIONS','" + hdnId.ClientID + "','',false,'500',600);"); btnRRBrowse.Attributes.Add("onclick", "return OpenWindow('FILEBROWSER','" + txtRRPath.ClientID + "','',false,400,600);"); btnWMBrowse.Attributes.Add("onclick", "return OpenWindow('FILEBROWSER','" + txtWMPath.ClientID + "','',false,400,600);"); btnCPBrowse.Attributes.Add("onclick", "return OpenWindow('FILEBROWSER','" + txtCPPath.ClientID + "','',false,400,600);"); btnCABrowse.Attributes.Add("onclick", "return OpenWindow('FILEBROWSER','" + txtCAPath.ClientID + "','',false,400,600);"); btnUsers.Attributes.Add("onclick", "return OpenWindow('SERVICE_USERS','" + hdnId.ClientID + "','',false,'500',500);"); btnReport.Attributes.Add("onclick", "return OpenServiceReport('/frame/report.aspx?r=" + oFunction.encryptQueryString("419") + "');"); if (Request.QueryString["expand"] != null) { btnExpand.Text = "Minimize All"; oTreeview.ExpandAll(); } else { btnExpand.Text = "Expand All"; oTreeview.ExpandDepth = 1; } oTreeview.Attributes.Add("oncontextmenu", "return false;"); }
protected void btnRename_Click(Object sender, EventArgs e) { try { if (strSecurity == "10" || strOwner == intProfile.ToString()) // If owner or share type is 'Edit' then allow else deny the operation { if (strType != "Folder") { System.IO.FileInfo oFile = new System.IO.FileInfo(strPath); if (oFile.Exists) { txtName.Text += strType; oFile.MoveTo(oFile.Directory.FullName + "\\" + txtName.Text); oFile.LastAccessTime = DateTime.Now; oFile.LastWriteTime = DateTime.Now; oCustomized.UpdateDocumentRepository(intDocId, txtName.Text, strType, GetVirtualPath(oFile.Directory.FullName + "\\" + txtName.Text)); } else { lblError.Text = "The file " + oFile.FullName + " does not exist"; } } else { DirectoryInfo oDir = new DirectoryInfo(strPath); if (oDir.Exists) { string strOldPath = oCustomized.GetDocumentRepository(intDocId, "path"); string strNewPath = GetVirtualPath(oDir.Parent.FullName + "\\" + txtName.Text); oDir.MoveTo(strNewPath); oDir.LastAccessTime = DateTime.Now; oDir.LastWriteTime = DateTime.Now; DataSet ds = oCustomized.GetDocumentRepositoryByParent(strOldPath); int intCount = 0; foreach (DataRow dr in ds.Tables[0].Rows) { int intId = Int32.Parse(dr["id"].ToString()); string strTemp1 = dr["path"].ToString(); string strTemp2 = dr["parent"].ToString(); if (intCount == 0) { oCustomized.UpdateDocumentRepository(intId, txtName.Text, "Folder", ""); } strTemp1 = strTemp1.Replace(strOldPath, strNewPath); strTemp2 = strTemp2.Replace(strOldPath, strNewPath); oCustomized.UpdateDocumentRepositoryParent(intId, strTemp2, strTemp1); intCount++; } } else { lblError.Text = "The directory " + oDir.FullName + " does not exist"; } } ClientScript.RegisterClientScriptBlock(typeof(Page), "redirect", "window.top.navigate(window.top.location);", true); } else { ClientScript.RegisterClientScriptBlock(typeof(Page), "msg", "alert('Access Denied !!');", true); } } catch (Exception exc) { txtName.Text = ""; lblError.Text = "Directory/File Rename Error: " + exc.Message; } }