Esempio n. 1
0
        public static bool CreateUploadRecord(User user, DateTime reqDate, string reqType, string fileName)
        {
            // uniquekey, preqdate, customer, partner, preqtype, preqaction, pfilename, pcustomfile, presultfile, presultdate, processed
            DBConnect connection = new DBConnect();
            bool      success    = false;

            try
            {
                connection.Connect(ConnectionsMgr.GetOCConnInfo(user, _Database.Home));
                var insertVals = new Dictionary <string, string>()
                {
                    { _Column.UniqueKey, connection.GetNewKey() },
                    { _Column.PReqDate, reqDate.ToString("yyyy-MM-dd HH:mm:ss") },
                    { _Column.Customer, user.Customer.SQLEscape() },
                    { _Column.PReqType, reqType.SQLEscape() },
                    { _Column.PFileName, fileName.SQLEscape() },
                    { _Column.PCustomFile, "1" },
                    { _Column.Partner, user.ActivePartner.SQLEscape() }
                };
                using (var res = connection.Insert(_Table.ProcessQ, insertVals.ToNameValueCollection()))
                {
                    success = res.AffectedRows != 0;
                }
                connection.Close();
                return(success);
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, "ProcessQueue", "CreateUploadRecord", e.Message);
                return(false);
            }
        }
Esempio n. 2
0
        public static Dictionary <string, string> GetReqTypeDict(User user)
        {
            Dictionary <string, string> ret = new Dictionary <string, string>();
            DBConnect connection            = new DBConnect();

            try
            {
                connection.Connect(ConnectionsMgr.GetAdminConnInfo());
                using (var query = connection.Select(new[] { _Column.TrxType, _Column.TrxDesc }, _Table.TrxInfo))
                {
                    while (query.Read())
                    {
                        ret.Add(query.Field(0), query.Field(1));
                    }
                }
                connection.Close();
                ret.Add("832_A", "Item Attributes");
                ret.Add("850_X", "PO Store X-Ref");
                ret.Add("856_X", "ASN Release X-Ref");
                ret.Add("832_P", "Al Tayer Item Attributes");
                return(ret);
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, "ProcessQueue", "GetReqTypeDict", e.Message);
                connection.Close();
                return(new Dictionary <string, string>());
            }
        }
Esempio n. 3
0
        public static List <ProcessRecord> GetPreviousRecords(User user)
        {
            List <ProcessRecord> listRecord = new List <ProcessRecord>();
            DBConnect            connection = new DBConnect();

            try
            {
                var filter = string.Format("WHERE {0}='{1}' AND {2}='{3}' AND {4}>'{5}'", _Column.Customer, user.Customer.SQLEscape(), _Column.Partner, user.ActivePartner.SQLEscape(), _Column.PReqDate, DateTime.Now.Subtract(new TimeSpan(30, 0, 0, 0)).ToString("yyyy-MM-dd HH:mm:ss"));
                connection.Connect(ConnectionsMgr.GetOCConnInfo(user, _Database.Home));
                using (var query = connection.Select(new[] { _Column.PReqDate, _Column.PReqType, _Column.Processed }, _Table.ProcessQ, filter))
                {
                    while (query.Read())
                    {
                        ProcessRecord pr = new ProcessRecord();
                        pr.Date   = query.Field(0, "");
                        pr.Type   = query.Field(1, "");
                        pr.Status = query.Field(2, "");
                        listRecord.Add(pr);
                    }
                }
                connection.Close();
                return(listRecord);
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, "ProcessQueue", "GetPreviousRecords", e.Message);
                connection.Close();
                return(new List <ProcessRecord>());
            }
        }
Esempio n. 4
0
        public static Dictionary <string, string> GetAllowedApps(User user)
        {
            DBConnect connection = new DBConnect();

            try
            {
                connection.Connect(ConnectionsMgr.GetOCConnInfo(user, _Database.Home));
                Dictionary <string, string> ret = new Dictionary <string, string>();

                using (var queryUserLevelAP = connection.Select(appFlags, _Table.UserInfo, string.Format("WHERE {0}='{1}' AND {2}='{3}' AND {4}='{5}'", _Column.Customer, user.Customer.SQLEscape(), _Column.Partner, user.ActivePartner.SQLEscape(), _Column.UserName, user.UserName.SQLEscape())))
                {
                    while (queryUserLevelAP.Read())
                    {
                        for (int i = 0; i < appFlags.Length; i++)
                        {
                            string f = queryUserLevelAP.Field(i);
                            if (f == "1")
                            {
                                string name = columnToDetail[appFlags[i]].appName;
                                string url  = columnToDetail[appFlags[i]].appURL;
                                if (!ret.ContainsKey(name))
                                {
                                    ret.Add(name, url);
                                }
                            }
                        }
                    }
                    if (ret.Count > 0)
                    {
                        return(ret);
                    }
                }

                using (var queryCustPartAP = connection.Select(appFlags, _Table.NetGroup, string.Format("WHERE {0}='{1}' AND {2}='{3}'", _Column.Customer, user.Customer.SQLEscape(), _Column.Partner, user.ActivePartner.SQLEscape())))
                {
                    while (queryCustPartAP.Read())
                    {
                        for (int i = 0; i < appFlags.Length; i++)
                        {
                            string f = queryCustPartAP.Field(i);
                            if (f == "1")
                            {
                                string name = columnToDetail[appFlags[i]].appName;
                                string url  = columnToDetail[appFlags[i]].appURL;
                                if (!ret.ContainsKey(name))
                                {
                                    ret.Add(name, url);
                                }
                            }
                        }
                    }
                    return(ret);
                }
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, nameof(AppManagement), nameof(GetAllowedApps), e.Message);
                return(new Dictionary <string, string>());
            }
        }
Esempio n. 5
0
        private static string _GetElemDesc(User user, string usEleNum, string usCode)
        {
            DBConnect connect = new DBConnect();

            try
            {
                connect.Connect(ConnectionsMgr.GetAdminConnInfo());
                var queryCodes = connect.Select(_Column.CodeDesc, _Table.DisaCode, string.Format("WHERE {0}='{1}' AND {2}='{3}'", _Column.EleNum, usEleNum.SQLEscape(), _Column.Code, usCode.SQLEscape()));
                if (queryCodes.Read())
                {
                    return(queryCodes.Field(0));
                }
                else
                {
                    return("");
                }
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, "ElementLookup", "_GetElemDesc", e.Message);
                return("");
            }
        }
Esempio n. 6
0
        public static bool IsAllowed(User user, AppID app)
        {
            try
            {
                if (user == null || app == AppID.None)
                {
                    return(false);
                }
                var connection = ConnectionsMgr.GetOCConnection(user);

                using (var queryUserLevelAP = connection.Select(idToColumn[app], _Table.UserInfo, string.Format("WHERE {0}='{1}' AND {2}='{3}' AND {4}='{5}'", _Column.Customer, user.Customer.SQLEscape(), _Column.Partner, user.ActivePartner.SQLEscape(), _Column.UserName, user.UserName.SQLEscape())))
                {
                    if (queryUserLevelAP.AffectedRows != 0)
                    {
                        queryUserLevelAP.Read();
                        return(queryUserLevelAP.Field(0) != "0");
                    }
                }

                using (var queryCustPartAP = connection.Select(idToColumn[app], _Table.NetGroup, string.Format("WHERE {0}='{1}' AND {2}='{3}'", _Column.Customer, user.Customer.SQLEscape(), _Column.Partner, user.ActivePartner.SQLEscape())))
                {
                    if (queryCustPartAP.AffectedRows == 0)
                    {
                        ProgramLog.LogError(user, nameof(AppManagement), nameof(IsAllowed), string.Format("Error: No information found for customer {0} and partner {1}.", user.Customer, user.ActivePartner));
                        return(false);
                    }
                    queryCustPartAP.Read();
                    return(queryCustPartAP.Field(0) != "0");
                }
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, nameof(AppManagement), nameof(IsAllowed), e.Message);
                return(false);
            }
        }