Beispiel #1
0
        public Action(int id)
        {
            List <string[]> get = DBAction.GetValue(DBQuery.Action + id);

            Desc   = get[0][1];
            Effect = get[0][3];
        }
        private async void Initialization(DBAction dBAction)
        {
            try
            {
                EnableGUIWait();
                idLookupTable = new Hashtable();

                if (dBAction.Equals(DBAction.StartFromScratch))
                {
                    await PrepareDB();
                    await SetDefaultTiers();
                }
                else if (dBAction.Equals(DBAction.StartOver))
                {
                    await DeleteTieringInDB();
                    await SetDefaultTiers();
                }

                await BuildOUStructure();

                if (dBAction.Equals(DBAction.StartFromScratch) || dBAction.Equals(DBAction.StartOver))
                {
                    await SetDefaultTiersForImprohoundCreatedOUs();
                }

                DisableGUIWait();
            }
            catch (Exception err)
            {
                // Error
                MessageBox.Show(err.Message.ToString() + "\n\n" + err.StackTrace.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                DisableGUIWait();
                MainWindow.BackToConnectPage();
            }
        }
Beispiel #3
0
        private void generateResponseFreqCodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GenerateSAS frm = new GenerateSAS();

            frm.ShowDialog();

            if (frm.DialogResult != DialogResult.OK)
            {
                return;
            }

            if (frm.Surv.SurveyCode.Equals(CurrentTiming.SurveyCode))
            {
                MessageBox.Show("Please choose a different survey than the current timing run.");
                return;
            }

            Survey survey = DBAction.GetSurveyInfo(CurrentTiming.SurveyCode);

            string sas = GenerateSASCodeResponseFreq(survey, frm.Surv);

            if (string.IsNullOrEmpty(sas))
            {
                return;
            }
            Directory.CreateDirectory(GetFilePath() + "\\Code");

            string filename = GetFilePath() + "\\Code\\" + CurrentTiming.SurveyCode + "-ResponseFrequencyCode.txt";

            File.WriteAllText(filename, sas);

            System.Diagnostics.Process.Start(filename);
        }
Beispiel #4
0
        public SurveyEntryFilter()
        {
            InitializeComponent();

            cboMain.DataSource    = DBAction.GetSurveyList();
            cboSurveys.DataSource = DBAction.GetSurveyList();
        }
Beispiel #5
0
        public IActionResult Post([FromBody] VoteItem value)
        {
            if (value == null)
            {
                return(BadRequest());
            }
            DBAction injj  = new DBAction();
            var      state = 0;

            ICache cache  = new ICache();
            UInt64 voteId = 0;

            if (cache.GetHash(value.Token, "session") != null && (voteId = injj.InsertVote(value)) > 0)
            {
                state = 1;
            }

            var data = new
            {
                State  = state,
                VoteId = voteId
            };

            var json = JObject.FromObject(data);

            return(new ObjectResult(json));
        }
Beispiel #6
0
        public TranslationViewer(int QID)
        {
            InitializeComponent();

            Translations = DBAction.GetQuestionTranslations(QID);

            if (Translations.Count == 0)
            {
                MessageBox.Show("No translations found for this question.");
                Close();
            }


            bs            = new BindingSource();
            bs.DataSource = Translations;

            navTranslations.BindingSource = bs;

            txtSurvey.DataBindings.Add(new Binding("Text", bs, "Survey"));
            txtVarName.DataBindings.Add(new Binding("Text", bs, "VarName"));
            txtLanguage.DataBindings.Add(new Binding("Text", bs, "Language"));
            Translation t = (Translation)bs.Current;

            rtbTranslationText.DataBindings.Add(new Binding("Rtf", bs, "TranslationRTF"));
        }
Beispiel #7
0
        public static long GetVoteCount()
        {
            DBAction injj = new DBAction();
            long     res  = injj.GetAllVoteCount();

            return(res);
        }
Beispiel #8
0
        public IActionResult Get()
        {
            string cc = Request.Query["id"];
            uint   id;

            try
            {
                id = uint.Parse(cc);
            }
            catch
            {
                return(BadRequest());
            }
            VoteItem res  = new VoteItem();
            DBAction injj = new DBAction();

            if (injj.GetVoteItem(id, ref res) != true || injj.getItemsInVote(id, ref res) != true)
            {
                return(BadRequest());
            }

            var json = JObject.FromObject(res);

            return(new ObjectResult(json));
        }
Beispiel #9
0
        public static int RenderToDb(Stream excelFileStream, string insertSql, DBAction dbAction, int sheetIndex, int headerRowIndex)
        {
            int num = 0;

            using (excelFileStream)
            {
                IWorkbook     workbook      = new HSSFWorkbook(excelFileStream);
                ISheet        sheetAt       = workbook.GetSheetAt(sheetIndex);
                StringBuilder stringBuilder = new StringBuilder();
                IRow          row           = sheetAt.GetRow(headerRowIndex);
                int           lastCellNum   = row.LastCellNum;
                int           lastRowNum    = sheetAt.LastRowNum;
                for (int i = sheetAt.FirstRowNum + 1; i <= lastRowNum; i++)
                {
                    IRow row2 = sheetAt.GetRow(i);
                    if (row2 != null)
                    {
                        stringBuilder.Append(insertSql);
                        stringBuilder.Append(" values (");
                        for (int j = row2.FirstCellNum; j < lastCellNum; j++)
                        {
                            stringBuilder.AppendFormat("'{0}',", GetCellValue(row2.GetCell(j)).Replace("'", "''"));
                        }
                        stringBuilder.Length--;
                        stringBuilder.Append(");");
                    }
                    if ((i % 50 == 0 || i == lastRowNum) && stringBuilder.Length > 0)
                    {
                        num += dbAction(stringBuilder.ToString());
                        stringBuilder.Length = 0;
                    }
                }
            }
            return(num);
        }
Beispiel #10
0
        // adds a question to the underlying survey's list of questions
        private void AddQuestion(string varname)
        {
            SurveyQuestion newQ = new SurveyQuestion();
            VariableName   newVar;
            string         newQnum = CurrentQuestion.Qnum;

            // get varname
            newQ.VarName.FullVarName = varname;
            // determine qnum
            if (CurrentQuestion.Qnum.Contains("!"))
            {
                newQnum += "00";
            }
            else
            {
                newQnum += "z";
            }

            if (newQnum.Length > 10)
            {
                MessageBox.Show("The Qnum for this new question is too long. Please limit the Qnum to 10 digits (including suffix). You may need to renumber the survey first.");
                return;
            }

            newQ.Qnum = newQnum;

            newVar = DBAction.GetVariable(newQ.VarName.FullVarName);
            if (newVar == null)
            {
                // if VarName does not exist, check refVarNames
                if (DBAction.RefVarNameExists(Utilities.ChangeCC(varname)))
                {
                    // display all the sets of the labels for this refVarName
                    VariableLabelSelector selector = new VariableLabelSelector(Utilities.ChangeCC(varname));
                    selector.frmParent = this;
                    selector.ShowDialog();
                }
            }
            else
            {
                // if VarName already exists, use those labels
                newQ.VarName.VarLabel = newVar.VarLabel;
                newQ.VarName.Domain   = new DomainLabel(newVar.Domain);
                newQ.VarName.Topic    = new TopicLabel(newVar.Topic);
                newQ.VarName.Content  = new ContentLabel(newVar.Content);
                newQ.VarName.Product  = new ProductLabel(newVar.Product);
            }

            // add to the list of questions, but after the current question
            CurrentSurvey.AddQuestion(newQ, bs.Position + 1);

            // go to the new question
            GoToQnum(newQ.Qnum);

            SaveRecord();

            Renumber = true;

            // TODO check for wave comments
        }
Beispiel #11
0
        // TODO finish

        private void DeleteQuestion()
        {
            if (MessageBox.Show(CurrentQuestion.VarName + " will be deleted from " + CurrentSurvey.SurveyCode + ". \r\n Do you want to proceed?", "Confirm Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                int nextID = bs.Position;

                // backup comments
                DBAction.BackupComments(CurrentQuestion.ID);
                // delete question from database
                DBAction.DeleteQuestion(CurrentQuestion.VarName.FullVarName, CurrentQuestion.SurveyCode);
                // remove question from the list
                CurrentSurvey.Questions.Remove(CurrentQuestion);
                // remove current item from bindingsource
                bs.RemoveCurrent();

                // refresh comments

                // delete varname if no more uses
                Renumber = true;
            }
            else
            {
                return;
            }

            if (MessageBox.Show("Do you want to document this deletion? (Click 'No' if you already have)", "Document", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
            }
            else
            {
            }
        }
Beispiel #12
0
        private int SaveRecord()
        {
            if (NewRecord)
            {
                if (DBAction.InsertQuestion(CurrentSurvey.SurveyCode, CurrentQuestion) == 1)
                {
                    return(1);
                }

                NewRecord = false;
                Dirty     = false;
            }
            else if (Dirty)
            {
                if (DBAction.UpdateQuestionWordings(CurrentQuestion) == 1)
                {
                    return(1);
                }

                //if (DBAction.UpdateLabels (CurrentQuestion) == 1)
                //  return 1;

                Dirty = false;
            }

            return(0);
        }
Beispiel #13
0
        public void IntegrateAsset(string ClientID, string UserID, string Token)
        {
            logger.Info("Scheduled Fleet complete asset job triggered");
            var client = new RestClient(_integrationAppSettings.AssetURL);

            client.Timeout = -1;
            var request = new RestRequest(Method.GET);

            request.AddHeader("ClientID", ClientID);
            request.AddHeader("UserID", UserID);
            request.AddHeader("Token", Token);
            IRestResponse response = client.Execute(request);
            AssetResp     ASResp   = new AssetResp();

            ASResp = JsonConvert.DeserializeObject <AssetResp>(response.Content);
            List <Vehicle> vehicles = new List <Vehicle>();

            if (ASResp.Errors == null)
            {
                foreach (var vsRes in ASResp.Data)
                {
                    try
                    {
                        Vehicle vh = new Vehicle();
                        vh.AssetId      = vsRes.ID;
                        vh.Registration = vsRes.LicensePlate;
                        vh.Make         = vsRes.Make;
                        vh.Model        = vsRes.Model;
                        string GuidID  = vsRes.ID;
                        var    CatType = AssetType(GuidID, ClientID, UserID, Token);
                        if (CatType != 0)
                        {
                            vh.Category = CatType;
                        }
                        if (vsRes.AssetType != null)
                        {
                            vh.Type = (vsRes.AssetType.ToString().Contains("Fleet")) ? 1 : 2;
                        }
                        else
                        {
                            vh.Type = 1;
                        }
                        vh.Active       = true;
                        vh.Availability = true;
                        vh.CreatedDate  = DateTime.Now;
                        vh.ModifiedDate = DateTime.Now;
                        if (vsRes.IsDeleted != null && vsRes.IsDeleted != true)
                        {
                            vehicles.Add(vh);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Info(ex.ToString() + ", Ids :" + vsRes.ID.ToString() + ", vsRes.LicensePlate:" + vsRes.LicensePlate.ToString());
                    }
                }
                DBAction dba = new DBAction(_integrationAppSettings);
                dba.IntegrateAssetsintoDB(vehicles);
            }
        }
Beispiel #14
0
 /// <summary>
 /// Upon closing the form, fill the Survey's questions with the selected comments.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CommentOptionsForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (CurrentSurvey.CommentFields.Count > 0)
     {
         DBAction.FillCommentsBySurvey(CurrentSurvey, CurrentSurvey.CommentFields, CurrentSurvey.CommentDate, CurrentSurvey.CommentAuthors, CurrentSurvey.CommentSources);
     }
 }
Beispiel #15
0
        public ResponseOptionUsage(string fieldname, string respName)
        {
            InitializeComponent();

            ResponseSets = DBAction.GetResponseSets(fieldname);

            bs = new BindingSource
            {
                DataSource = ResponseSets
            };
            bs.ListChanged           += Bs_ListChanged;
            navWordings.BindingSource = bs;
            this.MouseWheel          += WordingUsage_MouseWheel;


            // navigate to wordID
            foreach (ResponseSet r in ResponseSets)
            {
                if (r.RespSetName != respName)
                {
                    bs.MoveNext();
                }
                else
                {
                    break;
                }
            }
        }
Beispiel #16
0
        public IActionResult Post([FromBody] UserItem value)
        {
            if (value == null)
            {
                return(BadRequest());
            }
            DBAction injj  = new DBAction();
            ICache   cache = new ICache();

            var state  = 0;
            var userId = -1;
            var token  = "";

            UserItem item = new UserItem();

            item.UserName = value.UserName;
            item.Password = value.Password;
            token         = ControllerTools.CreateMD5Hash(userId + ControllerTools.GetTimeStamp());
            if ((userId = injj.CheckAccount(item)) >= 0 && cache.SetHash(token, "session", userId.ToString()))
            {
                state = 1;
            }

            var data = new
            {
                State  = state,
                Token  = token,
                UserId = userId
            };

            var json = JObject.FromObject(data);

            return(new ObjectResult(json));
        }
        public IActionResult Get()
        {
            string   cc   = Request.Query["userid"];
            DBAction injj = new DBAction();

            if (cc == null)
            {
                return(BadRequest());
            }
            string UserName = "";

            try
            {
                UserName = injj.GetUserNameFromUserId(uint.Parse(cc));
            }
            catch
            {
                return(BadRequest());
            }
            var res = new
            {
                UserName = UserName
            };
            var json = JObject.FromObject(res);

            return(new ObjectResult(json));
        }
Beispiel #18
0
        public void UpdateRefVarName(string refVarName)
        {
            Questions = new BindingList <SurveyQuestion>(DBAction.GetRefVarNameQuestionsGlob(refVarName, SurveyGlob));

            bs.DataSource = Questions;
            gridQuestions2.Refresh();
        }
Beispiel #19
0
        public List <FC_NDIS.JsonModels.SFDCBillingLines> GetBillingInformation()
        {
            DBAction dba = new DBAction(_integrationAppSettings);
            var      res = dba.GetBillingInformation();

            return(res);
        }
Beispiel #20
0
        private int SaveRecord()
        {
            if (NewRecord)
            {
                if (DBAction.InsertNote(CurrentNote.NoteText) == 1)
                {
                    return(1);
                }

                NewRecord = false;
                Dirty     = false;
            }
            else if (Dirty)
            {
                // if (DBAction.UpdateQuestionWordings(CurrentNote) == 1)
                //    return 1;

                //if (DBAction.UpdateLabels (CurrentNote) == 1)
                //  return 1;

                Dirty = false;
            }

            return(0);
        }
Beispiel #21
0
        public IActionResult Post([FromBody] UserItem value)
        {
            if (value == null)
            {
                return(BadRequest());
            }
            DBAction injj  = new DBAction();
            var      state = 0;

            UserItem item = new UserItem();

            item.UserName = value.UserName;
            item.Password = value.Password;

            if (injj.InsertUser(item))
            {
                state = 1;
            }

            var data = new
            {
                State    = state,
                UserName = value.UserName,
            };

            var json = JObject.FromObject(data);

            return(new ObjectResult(json));
        }
Beispiel #22
0
        /// <summary>
        /// Tries to save the current item to the database, either by inserting or updating. An ID of 0 means it is a new, unsaved record.
        /// </summary>
        /// <returns></returns>
        private int SaveRecord()
        {
            if (NewRecord) // new study created by this form
            {
                // insert into table
                if (DBAction.InsertCountry(CurrentStudy) == 1)
                {
                    return(1);
                }

                NewRecord = false;
                Dirty     = false;
                RefreshList(); // need to refresh to get the new ID
            }
            else if (Dirty)    // existing study edited
            {
                if (DBAction.UpdateStudy(CurrentStudy) == 1)
                {
                    return(1);
                }

                Dirty = false;
            }

            return(0);
        }
Beispiel #23
0
        public SurveyEntry(string surveyCode)
        {
            CurrentSurvey = DBAction.GetSurveyInfo(surveyCode);
            DBAction.FillQuestions(CurrentSurvey);

            if (CurrentSurvey.Questions == null)
            {
                MessageBox.Show("Error getting " + surveyCode + "'s questions. Ensure there is at least one question in this survey.");
                Close();
            }


            InitializeComponent();

            this.MouseWheel += SurveyEntry_OnMouseWheel;
            //txtPrePR.MouseWheel += SurveyEntry_OnMouseWheel;

            bs = new BindingSource
            {
                DataSource = CurrentSurvey.Questions
            };
            bs.PositionChanged += Bs_PositionChanged;

            navQuestions.BindingSource = bs;


            BindProperties();

            LockForm();

            ColorForm();
        }
        public SurveyNumbering(string surveyCode)
        {
            InitializeComponent();
            CurrentSurvey = DBAction.GetSurveyInfo(surveyCode);

            LoadSurvey();
        }
Beispiel #25
0
        public string GetAction(DBAction action)
        {
            string rstr = "";

            switch (action)
            {
            case DBAction.None:
                rstr = "{0}";
                break;

            case DBAction.Add:
                rstr = "向表{0}添加数据";
                break;

            case DBAction.Modify:
                rstr = "修改表{0}中的数据";
                break;

            case DBAction.Delete:
                rstr = "删除表{0}中的数据";
                break;

            case DBAction.Query:
                rstr = "查询表{0}中的数据";
                break;

            default:
                break;
            }
            return(string.Format(rstr, typeof(T)));
        }
Beispiel #26
0
        public WordingUsage(string fieldname, int wordID)
        {
            InitializeComponent();

            Wordings = DBAction.GetWordings(fieldname);

            bs = new BindingSource
            {
                DataSource = Wordings
            };
            bs.ListChanged += Bs_ListChanged;

            navWordings.BindingSource = bs;
            this.MouseWheel          += WordingUsage_MouseWheel;


            // navigate to wordID
            foreach (Wording w in Wordings)
            {
                if (w.WordID != wordID)
                {
                    bs.MoveNext();
                }
                else
                {
                    break;
                }
            }
        }
Beispiel #27
0
 public MainMenu()
 {
     InitializeComponent();
     Globals.CreateWorld();
     currentUser = DBAction.GetUser(Environment.UserName);
     // DBAction.FillUserSurveyFilters(currentUser);
     LabelSurveyEntryButtons();
 }
Beispiel #28
0
 public void LabelSurveyEntryButtons()
 {
     currentUser.SurveyEntryCodes.Clear();
     DBAction.FillUserSurveyFilters(currentUser);
     cmdOpenSurveyEntry.Text  = currentUser.SurveyEntryCodes[0];
     cmdOpenSurveyEntry2.Text = currentUser.SurveyEntryCodes[1];
     cmdOpenSurveyEntry3.Text = currentUser.SurveyEntryCodes[2];
 }
Beispiel #29
0
        private void UpdateRefVarName(string refVarName)
        {
            Questions = new BindingList <SurveyQuestion>(DBAction.GetRefVarNameQuestionsGlob(refVarName, SurveyGlob));

            bs.DataSource = Questions;

            UpdateTranslation();
        }
Beispiel #30
0
        public IActionResult Get(uint id)
        {
            string cc = Request.Query["userid"];

            DBAction injj = new DBAction();
            long     count;

            if (cc == null)
            {
                count = injj.GetAllVoteCount();
            }
            else
            {
                try
                {
                    count = injj.GetUserVoteCount(uint.Parse(cc));
                }
                catch
                {
                    return(BadRequest());
                }
            }
            if (id <= 0 || (id - 1) * 10 >= count)
            {
                return(BadRequest());
            }
            SplitPageRes res = new SplitPageRes();


            res.PageNum  = id;
            res.SplitNum = 10;
            if (cc == null)
            {
                if (!injj.GetVoteFromNThToMTh(ref res, (id - 1) * 10, id * 10, 10))
                {
                    res.State = 0;
                }
            }
            else
            {
                try
                {
                    if (!injj.GetVoteFromNThToMTh(ref res, (id - 1) * 10, id * 10, 10, uint.Parse(cc)))
                    {
                        res.State = 0;
                    }
                }
                catch
                {
                    return(BadRequest());
                }
            }

            res.State = 1;
            var json = JObject.FromObject(res);

            return(new ObjectResult(json));
        }
        public ViewDataClient()
        {
            tuObject = new TUObjects();
            tuObjectData = new TUObjectsDTO();
            dbAction = DBAction.Edit;

            listEnteredValues = new List<string>();
            referencedFieldsIds = new List<int>();

            listLabels = new List<Label>();
            listTextBoxes = new List<TextBox>();
            listButtons = new List<Button>();

            InitializeComponent();
        }
        public ViewDataClient(TUObjects tuObject, TUObjectsDTO tuObjectData, DBAction dbAction)
        {
            this.tuObject = tuObject;
            this.tuObjectData = tuObjectData;
            this.dbAction = dbAction;

            listEnteredValues = new List<string>();
            referencedFieldsIds = new List<int>();

            listLabels = new List<Label>();
            listTextBoxes = new List<TextBox>();
            listButtons = new List<Button>();

            InitializeComponent();
        }
 public void Instructions(DBObjectType objectType, DBAction action)
 {
     RenderText(scriptsGenerator.InstructionsForAutomaticRollback(objectType, action));
 }
Beispiel #34
0
    protected static void SendPTSelfBookingAlertEmail(int booking_id, DBAction dbAction, DateTime originalBookingStart, DateTime originalBookingEnd)
    {
        if (Utilities.IsDev()) return;
        if (!UserView.GetInstance().IsPatient) return;

        Booking booking = BookingDB.GetByID(booking_id);
        if (booking.BookingTypeID != 34) return;

        string emailAlertTo = ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["AdminAlertEmail_To"].Value; // "*****@*****.**"

        if (dbAction == DBAction.Insert)
        {
            // send pt alert email
            if (((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["EnableAlert_BookingAddedByPT"].Value == "1")
            {
                string subjectText = @"Notification that a PATIENT has added/moved/deleted their own booking";
                string mailText = @"This is an administrative email to notify you that a <b>patient</b> has <b>added</b> a booking for them self.

        <u>Patient making the appointment</u>
        " + booking.Patient.Person.FullnameWithoutMiddlename + " [ID: " + booking.Patient.PatientID + "]" + @"

        <u>Booking details</u>
        <table border=""0"" cellpadding=""2"" cellspacing=""2""><tr><td>Booking ID:</td><td>" + booking.BookingID + @"</td></tr><tr><td>Booking Date:</td><td>" + booking.DateStart.ToString("d MMM, yyyy") + " " + booking.DateStart.ToString("h:mm") + (booking.DateStart.Hour < 12 ? "am" : "pm") + "-" + booking.DateEnd.ToString("h:mm") + (booking.DateEnd.Hour < 12 ? "am" : "pm") + @"</td></tr><tr><td>Organisation:</td><td>" + booking.Organisation.Name + @"</td></tr><tr><td>Provider:</td><td>" + booking.Provider.Person.FullnameWithoutMiddlename + @"</td></tr><tr><td>Patient:</td><td>" + (booking.Patient == null ? "" : booking.Patient.Person.FullnameWithoutMiddlename + " [ID:" + booking.Patient.PatientID + "]") + @"</td></tr><tr><td>Status:</td><td>" + booking.BookingStatus.Descr + @"</td></tr></table>

        Please note that you can switch off these email alerts in the website settings page.

        Regards,
        Mediclinic
        ";
                Emailer.AsyncSimpleEmail(
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromEmail"].Value,
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value,
                    emailAlertTo,
                    subjectText,
                    mailText.Replace(Environment.NewLine, "<br />"),
                    true,
                    null);
            }
        }

        if (dbAction == DBAction.Update)
        {
            // send pt alert email
            if (((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["EnableAlert_BookingEditedByPT"].Value == "1")
            {
                string subjectText = @"Notification that a PATIENT has added/moved/deleted their own booking";
                string mailText = @"This is an administrative email to notify you that a <b>PATIENT</b> has <b>moved</b> a booking for them self.

        <u>Patient moving the appointment</u>
        " + booking.Patient.Person.FullnameWithoutMiddlename + " [ID: " + booking.Patient.PatientID + "]" + @"

        <u>Booking details</u>
        <table border=""0"" cellpadding=""2"" cellspacing=""2""><tr><td>Booking ID:</td><td>" + booking.BookingID + @"</td></tr><tr><td>Original Booking Date:</td><td>" + originalBookingStart.ToString("d MMM, yyyy") + " " + originalBookingStart.ToString("h:mm") + (originalBookingStart.Hour < 12 ? "am" : "pm") + "-" + originalBookingEnd.ToString("h:mm") + (originalBookingEnd.Hour < 12 ? "am" : "pm") + @"</td></tr><tr><td>New Booking Date:</td><td>" + booking.DateStart.ToString("d MMM, yyyy") + " " + booking.DateStart.ToString("h:mm") + (booking.DateStart.Hour < 12 ? "am" : "pm") + "-" + booking.DateEnd.ToString("h:mm") + (booking.DateEnd.Hour < 12 ? "am" : "pm") + @"</td></tr><tr><td>Organisation:</td><td>" + booking.Organisation.Name + @"</td></tr><tr><td>Provider:</td><td>" + booking.Provider.Person.FullnameWithoutMiddlename + @"</td></tr><tr><td>Patient:</td><td>" + (booking.Patient == null ? "" : booking.Patient.Person.FullnameWithoutMiddlename + " [ID:" + booking.Patient.PatientID + "]") + @"</td></tr><tr><td>Status:</td><td>" + booking.BookingStatus.Descr + @"</td></tr></table>

        Please note that you can switch off these email alerts in the website settings page.

        Regards,
        Mediclinic
        ";
                Emailer.AsyncSimpleEmail(
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromEmail"].Value,
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value,
                    emailAlertTo,
                    subjectText,
                    mailText.Replace(Environment.NewLine, "<br />"),
                    true,
                    null);
            }
        }

        if (dbAction == DBAction.Delete)
        {
            // send pt alert email
            if (((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["EnableAlert_BookingDeletedByPT"].Value == "1")
            {
                string subjectText = @"Notification that a PATIENT has added/moved/deleted their own booking";
                string mailText = @"This is an administrative email to notify you that a <b>patient</b> has <b>deleted</b> their booking.

        <u>Patient deleting the appointment</u>
        " + booking.Patient.Person.FullnameWithoutMiddlename + " [ID: " + booking.Patient.PatientID + "]" + @"

        <u>Booking details</u>
        <table border=""0"" cellpadding=""2"" cellspacing=""2""><tr><td>Booking ID:</td><td>" + booking.BookingID + @"</td></tr><tr><td>Booking Date:</td><td>" + booking.DateStart.ToString("d MMM, yyyy") + " " + booking.DateStart.ToString("h:mm") + (booking.DateStart.Hour < 12 ? "am" : "pm") + "-" + booking.DateEnd.ToString("h:mm") + (booking.DateEnd.Hour < 12 ? "am" : "pm") + @"</td></tr><tr><td>Organisation:</td><td>" + booking.Organisation.Name + @"</td></tr><tr><td>Provider:</td><td>" + booking.Provider.Person.FullnameWithoutMiddlename + @"</td></tr><tr><td>Patient:</td><td>" + (booking.Patient == null ? "" : booking.Patient.Person.FullnameWithoutMiddlename + " [ID:" + booking.Patient.PatientID + "]") + @"</td></tr><tr><td>Status:</td><td>" + booking.BookingStatus.Descr + @"</td></tr></table>

        Please note that you can switch off these email alerts in the website settings page.

        Regards,
        Mediclinic
        ";
                Emailer.AsyncSimpleEmail(
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromEmail"].Value,
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value,
                    emailAlertTo,
                    subjectText,
                    mailText.Replace(Environment.NewLine, "<br />"),
                    true,
                    null);
            }
        }

        bool booking_is_within_3_days = booking.DateStart.Date >= DateTime.Today && booking.DateStart.Date <= DateTime.Today.AddDays(3);
        if (dbAction == DBAction.Delete && booking_is_within_3_days)
        {
            // send email to PROVIDER
            if (((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["EnableAlert_BookingDeletedByPT"].Value == "1")
            {

                // Get Provider Email
                string[] emails = ContactDB.GetEmailsByEntityID(booking.Provider.Person.EntityID);

                string subjectText = @"Notification that your PATIENT has deleted their booking on " + booking.DateStart.ToString("d MMM, yyyy") + " at " + booking.DateStart.ToString("h:mm") + (booking.DateStart.Hour < 12 ? "am" : "pm") + " " + booking.Organisation.Name;
                string mailText = @"This is an administrative email to notify you that a <b>patient</b> has <b>deleted</b> their booking.

        <u>Patient deleting the appointment</u>
        " + booking.Patient.Person.FullnameWithoutMiddlename + " [ID: " + booking.Patient.PatientID + "]" + @"

        <u>Booking details</u>
        <table border=""0"" cellpadding=""2"" cellspacing=""2""><tr><td>Booking ID:</td><td>" + booking.BookingID + @"</td></tr><tr><td>Booking Date:</td><td><b>" + booking.DateStart.ToString("d MMM, yyyy") + " " + booking.DateStart.ToString("h:mm") + (booking.DateStart.Hour < 12 ? "am" : "pm") + "-" + booking.DateEnd.ToString("h:mm") + (booking.DateEnd.Hour < 12 ? "am" : "pm") + @"</b></td></tr><tr><td>Organisation:</td><td><b>" + booking.Organisation.Name + @"</b></td></tr><tr><td>Provider:</td><td>" + booking.Provider.Person.FullnameWithoutMiddlename + @"</td></tr><tr><td>Patient:</td><td><b>" + (booking.Patient == null ? "" : booking.Patient.Person.FullnameWithoutMiddlename + " [ID:" + booking.Patient.PatientID + "]") + @"</b></td></tr><tr><td>Status:</td><td>" + booking.BookingStatus.Descr + @"</td></tr></table>

        Regards,
        Mediclinic
        ";
                if (emails.Length > 0)
                    Emailer.AsyncSimpleEmail(
                        string.Join(",", emails),
                        ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value,
                        emailAlertTo,
                        subjectText,
                        mailText.Replace(Environment.NewLine, "<br />"),
                        true,
                        null);
            }
        }
    }
Beispiel #35
0
 public Entrants(TreeNode node, DBAction action, int ClassId, MainTreeNavigator mainTree)
     : base(node, action, ClassId, mainTree)
 {
     InitializeComponent();
 }
Beispiel #36
0
 /// <summary>
 /// Excel文档导入到数据库
 /// 默认取Excel的第一个表
 /// 第一行必须为标题行
 /// </summary>
 /// <param name="excelFileStream">Excel文档流</param>
 /// <param name="insertSql">插入语句</param>
 /// <param name="dbAction">更新到数据库的方法</param>
 /// <returns></returns>
 public static int RenderToDb(Stream excelFileStream, string insertSql, DBAction dbAction)
 {
     return RenderToDb(excelFileStream, insertSql, dbAction, 0, 0);
 }
Beispiel #37
0
        /// <summary>
        /// Excel文档导入到数据库
        /// </summary>
        /// <param name="excelFileStream">Excel文档流</param>
        /// <param name="insertSql">插入语句</param>
        /// <param name="dbAction">更新到数据库的方法</param>
        /// <param name="sheetIndex">表索引号,如第一个表为0</param>
        /// <param name="headerRowIndex">标题行索引号,如第一行为0</param>
        /// <returns></returns>
        public static int RenderToDb(Stream excelFileStream, string insertSql, DBAction dbAction, int sheetIndex, int headerRowIndex)
        {
            int rowAffected = 0;
            using (excelFileStream)
            {
                IWorkbook workbook = new HSSFWorkbook(excelFileStream);
                ISheet sheet = workbook.GetSheetAt(sheetIndex);
                StringBuilder builder = new StringBuilder();

                IRow headerRow = sheet.GetRow(headerRowIndex);
                int cellCount = headerRow.LastCellNum;//LastCellNum = PhysicalNumberOfCells
                int rowCount = sheet.LastRowNum;//LastRowNum = PhysicalNumberOfRows - 1

                for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++)
                {
                    IRow row = sheet.GetRow(i);
                    if (row != null)
                    {
                        builder.Append(insertSql);
                        builder.Append(" values (");
                        for (int j = row.FirstCellNum; j < cellCount; j++)
                        {
                            builder.AppendFormat("'{0}',", GetCellValue(row.GetCell(j)).Replace("'", "''"));
                        }
                        builder.Length = builder.Length - 1;
                        builder.Append(");");
                    }

                    if ((i % 50 == 0 || i == rowCount) && builder.Length > 0)
                    {
                        //每50条记录一次批量插入到数据库
                        rowAffected += dbAction(builder.ToString());
                        builder.Length = 0;
                    }

                }
            }
            return rowAffected;
        }