//private void SQLCreateJob() //{ // SQLDMO._SQLServer theServer = new SQLDMO.SQLServerClass(); // SQLDMO.Job theJob = new SQLDMO.Job(); // IIQCareSystem SQLManager; // SQLManager = (IIQCareSystem)ObjectFactory.CreateInstance("BusinessProcess.Security.BIQCareSystem, BusinessProcess.Security"); // string constr = SQLManager.GetServerInstance(); // string[] theConStr = constr.Split(';'); // theServer.Connect((theConStr[0].ToString().Split('='))[1].ToString().Trim(), (theConStr[1].ToString().Split('='))[1].ToString().Trim(), (theConStr[2].ToString().Split('='))[1].ToString().Trim()); // theJob.Name = "IQCare Auto-Backup"; // theJob.Description = "IQCare Auto-Backup"; // theJob.Category = "Database Maintenance"; // SQLDMO.JobStep theStep = new SQLDMO.JobStep(); // theStep.SubSystem = "TSQL"; // string theCmd = "declare @InstanceName varchar(1000) "; // theCmd += " declare @dir varchar(500)"; // theCmd += " set @dir = md " + ddBackupDrive.Text + "IQCareDBBackup"; // theCmd += " exec xp_cmdshell @dir"; // theCmd += " set @FileName = " + ddBackupDrive.Text + "IQCareDBBackup" + "\\IQCare + convert(varchar,getdate(),106) +'.bak'"; // theCmd += " set @InstanceName = 'iqcare_backup_' + convert(varchar,getdate(),106)"; // theCmd += " BACKUP DATABASE [IQCare] TO DISK = @FileName WITH NOFORMAT, NOINIT, NAME = @InstanceName, SKIP, REWIND, NOUNLOAD, STATS = 10"; // theStep.Command = theCmd; // theStep.OnSuccessAction = SQLDMO.SQLDMO_JOBSTEPACTION_TYPE.SQLDMOJobStepAction_QuitWithSuccess; // theStep.OnFailAction = SQLDMO.SQLDMO_JOBSTEPACTION_TYPE.SQLDMOJobStepAction_QuitWithFailure; // SQLDMO.JobSchedule theSchedule = new SQLDMO.JobSchedule(); // theSchedule.Schedule.FrequencyType = SQLDMO.SQLDMO_FREQUENCY_TYPE.SQLDMOFreq_Daily; // theSchedule.Schedule.FrequencyInterval = 1; // theSchedule.Schedule.ActiveStartDate = Convert.ToInt32(DateTime.Now.Date.ToString("yyyymmdd")); // theSchedule.Schedule.ActiveStartTimeOfDay = Convert.ToInt32(DateTime.Now.ToString("hhmmss")); // theSchedule.Schedule.ActiveEndDate = 99991231; // theSchedule.Schedule.ActiveEndTimeOfDay = 235959; // //theJob.Remove(); // theServer.JobServer.Jobs.Add(theJob); // theJob.ApplyToTargetServer((theConStr[0].ToString().Split('='))[1].ToString().Trim()); // theJob.JobSteps.Add(theStep); // theJob.BeginAlter(); // theStep.DoAlter(); // theJob.JobSchedules.Add(theSchedule); // theJob.DoAlter(); //} protected void btnOk_Click(object sender, EventArgs e) { int Paperlessclinic = this.chkPaperlessclinic.Checked == true ? 1 : 0; int Preferred = this.chkPreferred.Checked == true ? 1 : 0; DataTable dtModule = AddModule(); //int PMTCTclinic = this.chkPMTCT.Checked == true ? 1 : 0; IFacilitySetup FacilityMgr; IQCareUtils theUtils = new IQCareUtils(); if (Filelogo.PostedFile.FileName != "") { HttpPostedFile theFilelogo = Filelogo.PostedFile; theFilelogo.SaveAs(Server.MapPath(string.Format("..//images//{0}", txtfacilityname.Text + ".jpg"))); } Hashtable htFacilityParameters = new Hashtable(); htFacilityParameters.Add("FacilityLogo", txtfacilityname.Text + ".jpg"); htFacilityParameters.Add("FacilityAddress", txtFacAddress.Text); htFacilityParameters.Add("FacilityTel", txtFactele.Text); htFacilityParameters.Add("FacilityCell", txtFacCell.Text); htFacilityParameters.Add("FacilityFax", txtFacFax.Text); htFacilityParameters.Add("FacilityEmail", txtFacEmail.Text); htFacilityParameters.Add("FacilityFootertext", txtpharmfoottext.Text); htFacilityParameters.Add("FacilityURL", txtFacURL.Text); htFacilityParameters.Add("Facilitytemplate", this.Radio1.Checked == true ? Radio1.Value.ToString() : (this.Radio2.Checked == true ? Radio2.Value.ToString() : "0")); htFacilityParameters.Add("StrongPassword", this.chkStrongPwd.Checked == true ? 1 : 0); htFacilityParameters.Add("ExpirePaswordFlag", this.chkexpPwd.Checked == true ? 1 : 0); htFacilityParameters.Add("ExpirePaswordDays", this.chkexpPwd.Checked == true ? txtnoofdays.Text : ""); htFacilityParameters.Add("DateConstraint", this.chkdateconstraint.Checked == true ? 1 : 0); if (txtPEPFAR_Fund.Text.Trim() == "") { txtPEPFAR_Fund.Text = "01-01-1900"; } try { thePepFarDate = theUtils.MakeDate(txtPEPFAR_Fund.Text); FacilityMgr = (IFacilitySetup)ObjectFactory.CreateInstance("BusinessProcess.Administration.BFacility, BusinessProcess.Administration"); int Rows = FacilityMgr.UpdateFacility(Convert.ToInt32(ViewState["FacilityId"]), txtfacilityname.Text, txtcountryno.Text, txtLPTF.Text, txtSatelliteID.Text, txtNationalId.Text, Convert.ToInt32(ddlprovince.SelectedValue), Convert.ToInt32(ddldistrict.SelectedValue), theFName, Convert.ToInt32(cmbCurrency.SelectedValue), Convert.ToInt32(txtGrace.Text), "dd-MMM-yyyy", Convert.ToDateTime(thePepFarDate), Convert.ToInt32(ddStatus.SelectedValue), Convert.ToInt32(Session["SystemId"]), Preferred, Paperlessclinic, Convert.ToInt32(Session["AppUserId"]), dtModule, htFacilityParameters); Response.Redirect(".././frmLogin.aspx"); } catch (Exception err) { MsgBuilder theBuilder = new MsgBuilder(); theBuilder.DataElements["MessageText"] = err.Message.ToString(); IQCareMsgBox.Show("#C1", theBuilder, this); } finally { FacilityMgr = null; } }
//private void SQLCreateJob() //{ // SQLDMO._SQLServer theServer = new SQLDMO.SQLServerClass(); // SQLDMO.Job theJob = new SQLDMO.Job(); // IIQCareSystem SQLManager; // SQLManager = (IIQCareSystem)ObjectFactory.CreateInstance("BusinessProcess.Security.BIQCareSystem, BusinessProcess.Security"); // string constr = SQLManager.GetServerInstance(); // string[] theConStr = constr.Split(';'); // theServer.Connect((theConStr[0].ToString().Split('='))[1].ToString().Trim(), (theConStr[1].ToString().Split('='))[1].ToString().Trim(), (theConStr[2].ToString().Split('='))[1].ToString().Trim()); // theJob.Name = "IQCare Auto-Backup"; // theJob.Description = "IQCare Auto-Backup"; // theJob.Category = "Database Maintenance"; // SQLDMO.JobStep theStep = new SQLDMO.JobStep(); // theStep.SubSystem = "TSQL"; // string theCmd = "declare @InstanceName varchar(1000) "; // theCmd += " declare @dir varchar(500)"; // theCmd += " set @dir = md " + ddBackupDrive.Text + "IQCareDBBackup"; // theCmd += " exec xp_cmdshell @dir"; // theCmd += " set @FileName = " + ddBackupDrive.Text + "IQCareDBBackup" + "\\IQCare + convert(varchar,getdate(),106) +'.bak'"; // theCmd += " set @InstanceName = 'iqcare_backup_' + convert(varchar,getdate(),106)"; // theCmd += " BACKUP DATABASE [IQCare] TO DISK = @FileName WITH NOFORMAT, NOINIT, NAME = @InstanceName, SKIP, REWIND, NOUNLOAD, STATS = 10"; // theStep.Command = theCmd; // theStep.OnSuccessAction = SQLDMO.SQLDMO_JOBSTEPACTION_TYPE.SQLDMOJobStepAction_QuitWithSuccess; // theStep.OnFailAction = SQLDMO.SQLDMO_JOBSTEPACTION_TYPE.SQLDMOJobStepAction_QuitWithFailure; // SQLDMO.JobSchedule theSchedule = new SQLDMO.JobSchedule(); // theSchedule.Schedule.FrequencyType = SQLDMO.SQLDMO_FREQUENCY_TYPE.SQLDMOFreq_Daily; // theSchedule.Schedule.FrequencyInterval = 1; // theSchedule.Schedule.ActiveStartDate = Convert.ToInt32(DateTime.Now.Date.ToString("yyyymmdd")); // theSchedule.Schedule.ActiveStartTimeOfDay = Convert.ToInt32(DateTime.Now.ToString("hhmmss")); // theSchedule.Schedule.ActiveEndDate = 99991231; // theSchedule.Schedule.ActiveEndTimeOfDay = 235959; // //theJob.Remove(); // theServer.JobServer.Jobs.Add(theJob); // theJob.ApplyToTargetServer((theConStr[0].ToString().Split('='))[1].ToString().Trim()); // theJob.JobSteps.Add(theStep); // theJob.BeginAlter(); // theStep.DoAlter(); // theJob.JobSchedules.Add(theSchedule); // theJob.DoAlter(); //} protected void btnOk_Click(object sender, EventArgs e) { int Paperlessclinic = this.chkPaperlessclinic.Checked == true ? 1 : 0; int Preferred = this.chkPreferred.Checked == true ? 1 : 0; DataTable dtModule = AddModule(); DataTable dtStore = AddStores(); //int PMTCTclinic = this.chkPMTCT.Checked == true ? 1 : 0; IFacilitySetup FacilityMgr; IQCareUtils theUtils = new IQCareUtils(); if (Filelogo.PostedFile.FileName != "") { HttpPostedFile theFilelogo = Filelogo.PostedFile; theFilelogo.SaveAs(Server.MapPath(string.Format("..//images//{0}", txtfacilityname.Text + ".jpg"))); } Hashtable htFacilityParameters = getFacilityParameters(); if (txtPEPFAR_Fund.Value.Trim() == "") { txtPEPFAR_Fund.Value = "01-01-1900"; } try { thePepFarDate = theUtils.MakeDate(txtPEPFAR_Fund.Value); FacilityMgr = (IFacilitySetup)ObjectFactory.CreateInstance("BusinessProcess.Administration.BFacility, BusinessProcess.Administration"); int Rows = FacilityMgr.UpdateFacility(Convert.ToInt32(ViewState["FacilityId"]), txtfacilityname.Text, CountryId.ToString(), txtLPTF.Text, txtSatelliteID.Text, txtNationalId.Text, Convert.ToInt32(ddlprovince.SelectedValue), Convert.ToInt32(ddldistrict.SelectedValue), theFName, Convert.ToInt32(cmbCurrency.SelectedValue), Convert.ToInt32(txtGrace.Text), "dd-MMM-yyyy", Convert.ToDateTime(thePepFarDate), Convert.ToInt32(ddStatus.SelectedValue), Convert.ToInt32(Session["SystemId"]), Preferred, Paperlessclinic, Convert.ToInt32(Session["AppUserId"]), dtModule, htFacilityParameters, dtStore); Response.Redirect(".././frmLogin.aspx"); } catch (Exception err) { MsgBuilder theBuilder = new MsgBuilder(); theBuilder.DataElements["MessageText"] = err.Message.ToString(); IQCareMsgBox.Show("#C1", theBuilder, this); } finally { FacilityMgr = null; } }