Example #1
0
        private void INIT()
        {
            DataTable dt = null;
            StringBuilder sb = new StringBuilder();
            sb.Append("select idx, title from FIRMS order by title asc");

            using (FirebirdDBHelper db = new FirebirdDBHelper(sb.ToString(), util.strDBConn))
            {
                try
                {
                    dt = db.GetDataTable();
                }
                catch (FirebirdSql.Data.FirebirdClient.FbException fex)
                {
                    util.WriteLog(string.Format("{0} INIT ERR : {1}", this.GetType(), fex.Message));
                    return;
                }
            }

            _list = new List<Firm>(
                (from _row in dt.AsEnumerable()
                 select new Firm()
                 {
                     idx = int.Parse(_row["idx"].ToString())
                     ,
                     title = _row["title"].ToString()
                 }
                ).ToList<Firm>()
            );
        }
Example #2
0
        private void INIT()
        {
            DataTable dt = null;
            StringBuilder sb = new StringBuilder();
            sb.Append("select innertel, title from EXCEPTIONS order by innertel asc");

            using (FirebirdDBHelper db = new FirebirdDBHelper(sb.ToString(), util.strDBConn))
            {
                try
                {
                    dt = db.GetDataTable();
                }
                catch (FirebirdSql.Data.FirebirdClient.FbException fex)
                {
                    util.WriteLog(string.Format("{0} INIT ERR : {1}", this.GetType(), fex.Message));
                    return;
                }
            }

            _list = new ObservableCollection<BILLException>(
                (from _row in dt.AsEnumerable()
                 select new BILLException()
                 {
                     innertel = _row[0].ToString()
                     , title = _row[1].ToString()
                 }
                ).ToList<BILLException>()
            );
        }
Example #3
0
        private async void ShowLoginDialog()
        {
            //this.MetroDialogOptions.ColorScheme = UseAccentForDialogsMenuItem.IsChecked ? MetroDialogColorScheme.Accented : MetroDialogColorScheme.Theme;
            LoginDialogData result = await this.ShowLoginAsync("Authentication", "Enter your credentials", new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme, InitialUsername = string.Empty });
            if (result == null)
            {
                //User pressed cancel
                this.Close();
            }
            else
            {
                //MessageDialogResult messageResult = await this.ShowMessageAsync("Authentication Information", String.Format("Username: {0}\nPassword: {1}", result.Username, result.Password));
                DataTable dt = null;
                StringBuilder query = new StringBuilder();
                query.Append(" select idx, identity, pwd, firm_idx, role_idx from users ");
                query.AppendFormat(" where identity='{0}' and pwd='{1}'", result.Username.Trim(), util.GetSHA1(result.Password));
                using (FirebirdDBHelper db = new FirebirdDBHelper(query.ToString(), util.strDBConn))
                {
                    try
                    {
                        dt = db.GetDataTable();
                    }
                    catch
                    {
                        dt = null;
                    }
                }

                if (dt == null || dt.Rows.Count == 0)
                {
                    // do when login failed
                    MessageDialogResult messageResult = await this.ShowMessageAsync("Authentication", "Logon failed.\r\nPlease, identify your information one more time.");
                    ShowLoginDialog();
                }
                else
                {
                    // succeed
                }
            }
        }
Example #4
0
        private void INIT()
        {
            DataTable dt = null;
            StringBuilder sb = new StringBuilder();
            sb.Append("select idx, areacode, nation_num, nation_local_num, natione, nationk, lm from INTERNATIONAL order by nationk asc");

            using (FirebirdDBHelper db = new FirebirdDBHelper(sb.ToString(), util.strDBConn))
            {
                try
                {
                    dt = db.GetDataTable();
                }
                catch (FirebirdSql.Data.FirebirdClient.FbException fex)
                {
                    util.WriteLog(string.Format("{0} INIT ERR : {1}", this.GetType(), fex.Message));
                    return;
                }
            }

            _list = new ObservableCollection<INTERNATIONAL>(
                (from _row in dt.AsEnumerable()
                 select new INTERNATIONAL()
                 {
                     idx = long.Parse(_row["idx"].ToString())
                     ,
                     areacode = int.Parse(_row["areacode"].ToString())
                     ,
                     nation_num = _row["nation_num"].ToString()
                     ,
                     nation_local_num = _row["nation_local_num"].ToString()
                     ,
                     natione = _row["natione"].ToString()
                     ,
                     nationk = _row["nationk"].ToString()
                     ,
                     lm = _row["lm"].ToString()
                 }
                ).ToList<INTERNATIONAL>()
            );
        }
Example #5
0
        private void INIT()
        {
            DataTable dt = null;
            StringBuilder sb = new StringBuilder();
            sb.Append("select prefix, type, rate, sec from DOMESTIC_RATE order by prefix asc");

            using (FirebirdDBHelper db = new FirebirdDBHelper(sb.ToString(), util.strDBConn))
            {
                try
                {
                    dt = db.GetDataTable();
                }
                catch (FirebirdSql.Data.FirebirdClient.FbException fex)
                {
                    util.WriteLog(string.Format("{0} INIT ERR : {1}", this.GetType(), fex.Message));
                    return;
                }
            }

            _list = new ObservableCollection<DOMESTICRATE>(
                (from _row in dt.AsEnumerable()
                 select new DOMESTICRATE()
                 {
                     prefix = _row["prefix"].ToString()
                     ,
                     type = _row["type"].ToString()
                     ,
                     rate = float.Parse(_row["rate"].ToString())
                     ,
                     sec = int.Parse(_row["sec"].ToString())
                 }
                ).ToList<DOMESTICRATE>()
            );
        }
Example #6
0
        private void INIT()
        {
            DataTable dt = null;
            StringBuilder sb = new StringBuilder();
            sb.Append("select areacode, lrate, lsec, mrate, msec from INTERNATIONAL_RATE order by areacode asc");

            using (FirebirdDBHelper db = new FirebirdDBHelper(sb.ToString(), util.strDBConn))
            {
                try
                {
                    dt = db.GetDataTable();
                }
                catch (FirebirdSql.Data.FirebirdClient.FbException fex)
                {
                    util.WriteLog(string.Format("{0} INIT ERR : {1}", this.GetType(), fex.Message));
                    return;
                }
            }

            _list = new ObservableCollection<INTERNATIONALRATE>(
                (from _row in dt.AsEnumerable()
                 select new INTERNATIONALRATE()
                 {
                     areacode = int.Parse(_row["areacode"].ToString())
                     ,
                     lrate = double.Parse(_row["lrate"].ToString())
                     ,
                     lsec = int.Parse(_row["lsec"].ToString())
                     ,
                     mrate = double.Parse(_row["mrate"].ToString())
                     ,
                     msec = int.Parse(_row["msec"].ToString())
                 }
                ).ToList<INTERNATIONALRATE>()
            );
        }
Example #7
0
        private bool CDRInfoValidate(out DataTable dt)
        {
            dt = null;
            bool result = false;

            //DataTable dt = null;

            var tmparr = _extnum.Split(',');
            string tmpext = string.Empty;
            if (!string.IsNullOrEmpty(_extnum))
            {
                for (int k = 0; k < tmparr.Length; k++)
                {
                    if (string.IsNullOrEmpty(tmpext))
                    {
                        tmpext = "'" + tmparr[k] + "'";
                    }
                    else
                    {
                        tmpext += ",'" + tmparr[k] + "'";
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("select first 2 * from tbl_log where 1=1 and room in ({0}) and (chk=1 or chk=0) order by room asc, regdate desc", tmpext);

            using (FirebirdDBHelper db = new FirebirdDBHelper(sb.ToString(), util.strDBConn))
            {
                try
                {
                    dt = db.GetDataTable();
                }
                catch (FirebirdSql.Data.FirebirdClient.FbException fex)
                {
                    util.WriteLog(string.Format("{0} INIT ERR : {1}", this.GetType(), fex.Message));
                }
            }

            if (dt.Rows.Count <= 0)
            {
                result = false;
            }
            else
            {
                if (dt.Rows[0][3].ToString().Equals("0"))
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }

            return result;
        }
Example #8
0
        private void GetCDRInfo2(out DataTable dt)
        {
            dt = null;
            StringBuilder sb = new StringBuilder();

            sb.Append("select seq, caller, callee, startdate, enddate, result, caller_type, callee_type from cdrinfo where 1=1");
            if (!string.IsNullOrEmpty(_extnum))
            {
                var tmparr = _extnum.Split(',');
                string tmpext = string.Empty;
                for (int k = 0; k < tmparr.Length; k++)
                {
                    if (string.IsNullOrEmpty(tmpext))
                    {
                        tmpext = "'" + tmparr[k] + "'";
                    }
                    else
                    {
                        tmpext += ",'" + tmparr[k] + "'";
                    }
                }
                sb.AppendFormat(" and caller in ({0})", tmpext);
            }
            sb.AppendFormat(" and startdate between cast('{0}' as timestamp) and cast('{1}' as timestamp)", ((DateTime)sdate.Value).ToShortDateString(), ((DateTime)edate.Value).ToShortDateString());
            sb.Append(" and caller_type=0");
            sb.Append(" and result=0");
            sb.Append(" order by caller asc, startdate asc");

            using (FirebirdDBHelper db = new FirebirdDBHelper(sb.ToString(), util.strDBConn))
            {
                try
                {
                    dt = db.GetDataTable();
                }
                catch (FirebirdSql.Data.FirebirdClient.FbException fex)
                {
                    util.WriteLog(string.Format("{0} INIT ERR : {1}", this.GetType(), fex.Message));
                }
            }
        }
Example #9
0
        private bool GetCDRInfo(out DataTable dt)
        {
            StringBuilder sb = new StringBuilder();
            dt = null;

            //if (chkout.IsChecked == true ? true : false)
            //{
                bool valid = CDRInfoValidate(out dt);
                if (!valid)
                {
                    return false;
                }
                else
                {
                    sb.Append("select seq, caller, callee, startdate, enddate, result, caller_type, callee_type from cdrinfo where 1=1");
                    if (!string.IsNullOrEmpty(_extnum))
                    {
                        var tmparr = _extnum.Split(',');
                        string tmpext = string.Empty;
                        for (int k = 0; k < tmparr.Length; k++)
                        {
                            if (string.IsNullOrEmpty(tmpext))
                            {
                                tmpext = "'" + tmparr[k] + "'";
                            }
                            else
                            {
                                tmpext += ",'" + tmparr[k] + "'";
                            }
                        }
                        sb.AppendFormat(" and caller in ({0})", tmpext);
                    }
                    sb.AppendFormat(" and startdate between cast('{0}' as timestamp) and cast('{1}' as timestamp)", DateTime.Parse(dt.Rows[1][4].ToString()).ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Parse(dt.Rows[0][4].ToString()).ToString("yyyy-MM-dd HH:mm:ss"));
                    sb.Append(" and caller_type=0");
                    sb.Append(" and result=0");
                    sb.Append(" order by caller asc, startdate asc");

                    using (FirebirdDBHelper db = new FirebirdDBHelper(sb.ToString(), util.strDBConn))
                    {
                        try
                        {
                            dt = db.GetDataTable();
                        }
                        catch (FirebirdSql.Data.FirebirdClient.FbException fex)
                        {
                            util.WriteLog(string.Format("{0} INIT ERR : {1}", this.GetType(), fex.Message));
                        }
                    }
                    return true;
                }
            //}

            /*
            sb.Append("select seq, caller, callee, startdate, enddate, result, caller_type, callee_type from cdrinfo where 1=1");
            if (!string.IsNullOrEmpty(_extnum))
            {
                var tmparr = _extnum.Split(',');
                string tmpext = string.Empty;
                for (int k = 0; k < tmparr.Length; k++)
                {
                    if (string.IsNullOrEmpty(tmpext))
                    {
                        tmpext = "'" + tmparr[k] + "'";
                    }
                    else
                    {
                        tmpext += ",'" + tmparr[k] + "'";
                    }
                }
                sb.AppendFormat(" and caller in ({0})", tmpext);
            }
            sb.AppendFormat(" and cast(startdate as date) between cast('{0}' as date) and cast('{1}' as date)", ((DateTime)sdate.Value).ToShortDateString(), ((DateTime)edate.Value).ToShortDateString());
            sb.Append(" and caller_type=0");
            sb.Append(" and result=0");
            sb.Append(" order by caller asc, startdate asc");

            using (FirebirdDBHelper db = new FirebirdDBHelper(sb.ToString(), util.strDBConn))
            {
                try
                {
                    dt = db.GetDataTable();
                }
                catch (FirebirdSql.Data.FirebirdClient.FbException fex)
                {
                    util.WriteLog(string.Format("{0} INIT ERR : {1}", this.GetType(), fex.Message));
                }
            }

            return true;
            */
        }