public dynamic viewIdtReferenceNumber()
        {
            //  List<firstForm> IdtIctInList = new List<firstForm>();
            List <InData> data = new List <InData>();

            using (var connection = new SqlConnection(sqlConnectionString))
            {
                var IdtrefNumberList = connection.Query <firstForm>("Select * from IdtIcTMaster WHERE Status='InProgress'").ToList();
                //   var list = DataTableToJSONWithJSONNet(refNumberList);
                // dynamic json = JsonConvert.DeserializeObject(list);
                for (int i = 0; i < IdtrefNumberList.Count; i++)
                {
                    InData refList = new InData();
                    refList.Id = IdtrefNumberList[i].Id;
                    refList.ReferenceNumber = IdtrefNumberList[i].ReferenceNumber;
                    refList.Type            = IdtrefNumberList[i].IdtIctType;
                    data.Add(refList);
                }
                var cpLprefNumberList = connection.Query <CPLTMaster>("Select * from CPLTMaster WHERE Status='Completed'").ToList();
                for (int i = 0; i < cpLprefNumberList.Count; i++)
                {
                    InData refList = new InData();
                    refList.Id = cpLprefNumberList[i].Id;
                    refList.ReferenceNumber = cpLprefNumberList[i].ReferenceNumber;
                    refList.Type            = cpLprefNumberList[i].Type;
                    data.Add(refList);
                }
                IdtReferenceData IdtReferenceData = new IdtReferenceData();
                IdtReferenceData.ReferenceData = data;
                return(IdtReferenceData);
            }
        }
        private Result InData_DetectSqlInjection_testcase(string injectionString, bool injectionYN)
        {
            bool   isInjection = InData.DetectSqlInjection(injectionString);
            Result ok          = Assert.That(isInjection, Is.equal_to, injectionYN, "InData", "DetectSqlInjection");

            return(ok);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- ElementExists -->
        /// <summary>
        ///      Looks for element exists on direct id transfer transformations (instructions)
        /// </summary>
        /// <param name="module"></param>
        /// <param name="field"></param>
        /// <param name="tableName"></param>
        /// <param name="aspect"></param>
        /// <returns></returns>
        protected bool ElementExists(string tableName, DataRow field, InfoAspect aspect)
        {
            bool exists = false;

            try
            {
                if (tableName == "Level_1") // "V"
                {
                    TransformField transform      = Transform["Level_1_ID"];
                    SqlInt32       extractPkValue = InData.GetSqlInt32(transform.XrefLookup);
                    string         loadPkColumn   = ColumnName_LoadId(tableName, aspect.Enter()); aspect--;
                    exists = CheckElementExists(tableName, loadPkColumn, extractPkValue, aspect.Enter()); aspect--;
                }
                else
                {
                    // ------------------------------------------------------------------
                    //  The normal direct 1 to 1 conversion case
                    // ------------------------------------------------------------------
                    string   extractPkColumn = ColumnName_ExtractPkFromLoad(tableName, aspect.Enter()); aspect--;
                    SqlInt32 extractPkValue  = InData.GetSqlInt32(field, extractPkColumn);
                    string   loadPkColumn    = ColumnName_LoadId(tableName, aspect.Enter()); aspect--;
                    exists = CheckElementExists(tableName, loadPkColumn, extractPkValue, aspect.Enter()); aspect--;
                }
            }
            catch (Exception ex) { Pause(); aspect.Rethrow(ex); }

            return(exists);
        }
        private Result InData_DatabaseIdentity_testcase(string conn, string target)
        {
            string identity = InData.DatabaseIdentity(conn);
            Result result   = Assert.That(identity, Is.equal_to, target, "InData", "DatabaseIdentity");

            return(result);
        }
Exemple #5
0
 private CryptoContainer(CryptoRequest request, bool createForEncryption)
 {
     if (request.EmbedSalt)
     {
         Flags = CryptoContainerFlags.HasSalt;
         Salt  = request.Salt;
     }
     else
     {
         Salt = new byte[32];
     }
     if (!createForEncryption)
     {
         Salt = request.Salt;
     }
     IV = request.IV;
     if (createForEncryption)
     {
         OutData = request.OutData;
     }
     else
     {
         InData = request.InData;
         long currentPosition = InData.Position;
         InData.Position = 0;
         _headerData     = new byte[HeaderSize];
         InData.Read(_headerData, 0, HeaderSize);
         InData.Position = 0;
     }
     Key       = request.Key;
     _password = request.Password;
 }
 /***************************************/
 void Start()
 {
     inData     = new InData();
     population = GameObject.FindGameObjectWithTag("HCharacter").GetComponent <Population>();
     army       = GameObject.FindGameObjectWithTag("HCharacter").GetComponent <Army>();
     worker     = GameObject.FindGameObjectWithTag("HCharacter").GetComponent <Workers>();
     StartCoroutine(Send());
 }
Exemple #7
0
        // ----------------------------------------------------------------------------------------
        /// <!-- GetRaceFromBits -->
        /// <summary>
        ///      Converts the race indicators from CANVaS into the raceId in VABHAS
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public static SqlInt32 GetRaceFromBits(DataRow field)
        {
            // ------------------------------------------------------------------
            //  Get the bits
            // ------------------------------------------------------------------
            SqlBoolean black  = InData.GetSqlBoolean(field, "Race_Black_Ind");
            SqlBoolean yellow = InData.GetSqlBoolean(field, "Race_Asian_Ind");
            SqlBoolean brown  = InData.GetSqlBoolean(field, "Race_Hawaiian_Ind");
            SqlBoolean red    = InData.GetSqlBoolean(field, "Race_Native_Am_Ind");
            SqlBoolean white  = InData.GetSqlBoolean(field, "Race_White_Ind");


            // ------------------------------------------------------------------
            //  Add the bits
            // ------------------------------------------------------------------
            int total = 0
                        + (int)black.ToSqlInt32()
                        + (int)yellow.ToSqlInt32()
                        + (int)brown.ToSqlInt32()
                        + (int)red.ToSqlInt32()
                        + (int)white.ToSqlInt32();


            // ------------------------------------------------------------------
            //  Use the bits
            // ------------------------------------------------------------------
            SqlInt32 raceId = SqlInt32.Null;

            if (total > 1)
            {
                raceId = 13;               // 13. Two or more races.
            }
            else if (black)
            {
                raceId = 1;                // 1.  African American
            }
            else if (yellow)
            {
                raceId = 2;                // 2.  Asian
            }
            else if (brown)
            {
                raceId = 3;                // 3.  Native Hawaiian
            }
            else if (red)
            {
                raceId = 4;                // 4.  American Indian
            }
            else if (white)
            {
                raceId = 5;                // 5.  Caucasian
            }
            else
            {
                raceId = 14;               // 14. Decline to Identify
            }
            return(raceId);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- Update -->
        /// <summary>
        ///      Updates a row in one of the location related tables
        /// </summary>
        /// <param name="updateQuery"></param>
        /// <param name="field"></param>
        /// <param name="importedData"></param>
        /// <param name="aspect"></param>
        private SqlInt32 Update(string tableName, DataRow field, DataTable importedData, InfoAspect aspect)
        {
            if (tableName == "Instructions")
            {
                string updateQuery = "";
                object obj         = null;

                using (SqlCommand cmd = new SqlCommand(updateQuery, aspect.SecondaryConnection))
                {
                    try
                    {
                        // --------------------------------------------------------------
                        //  Fill the command
                        // --------------------------------------------------------------
                        //UpdateQueryFill(cmd, tableName, field, aspect.Enter(Name, "QueryFill")); aspect--;
                        foreach (string transformKey in Transform.Keys)
                        {
                            AddParameterToLoad(cmd, tableName, field, transformKey, aspect.Enter()); aspect--;
                        }


                        // --------------------------------------------------------------
                        //  Perform the insert
                        // --------------------------------------------------------------
                        obj = ExecuteScalar(cmd, tableName, aspect.Enter()); aspect--;

                        string report = InData.AsciiNewQuery(cmd);


                        if (obj != null)
                        {
                            SqlInt32 id = (SqlInt32)obj;


                            // ------------------------------------------------------------------
                            //  Record the insert
                            // ------------------------------------------------------------------
                            if (id > 0)
                            {
                                int row = importedData.Rows.Count;
                                importedData.ImportRow(field);
                                importedData.Rows[row][tableName + "DbId"] = id;
                                field[RealIdColumn] = id;
                            }
                        }
                        else
                        {
                            string report2 = InData.AsciiNewQuery(cmd);
                        }
                    }
                    catch (SqlException ex) { Pause(); string report = InData.AsciiNewQuery(cmd); aspect.Rethrow(ex); }
                    catch (Exception ex) { Pause(); string report = InData.AsciiNewQuery(cmd); aspect.Rethrow(ex); }
                }
            }
            return(0);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- InsureFileHeader -->
        /// <summary>
        ///      Insures that the csv file used has a header row, both creates the path and writes the copy file
        /// </summary>
        /// <param name="importFilePath1"></param>
        /// <param name="headerLine"></param>
        /// <param name="keepHeaders">
        ///      Indicates if to keep or strip off customer supplied headers
        /// </param>
        /// <returns></returns>
        public static string InsureFileHeader(string importFilePath1, string headerLine
                                              , bool keepHeaders, string copyOfprefix)
        {
            string importFilePath = importFilePath1;


            if (keepHeaders)
            {
                // ----------------------------------------------------------------------
                //  Come up with a new path for a new import file if there is no header row in the csv file
                // ----------------------------------------------------------------------
                string content = InData.GetStringFromFile(importFilePath1);

                if (string.IsNullOrEmpty(content.Trim()) ||
                    Regex.IsMatch(content.Substring(0, 1), "[0-9]"))
                {
                    importFilePath = InData.PrependToFileName(copyOfprefix, importFilePath1);
                    importFilePath = Regex.Replace(importFilePath, ".txt$", ".csv");
                }


                // ----------------------------------------------------------------------
                //  Prepend the header if it is needed
                // ----------------------------------------------------------------------
                if (string.IsNullOrEmpty(content.Trim()) ||
                    Regex.IsMatch(content.Substring(0, 1), "[0-9]"))
                {
                    // There is no header, add one
                    string content2 = headerLine + "\r\n" + content;
                    InData.WriteStringToFile(importFilePath, content2, false);
                }
            }
            else
            {
                string content1 = InData.GetStringFromFile(importFilePath1);
                string content2 = content1;
                if (!string.IsNullOrEmpty(content1.Trim()) && !Regex.IsMatch(content1.Substring(0, 1), "[0-9]"))
                {
                    //  There is a header, strip it off and add one
                    content2 = Regex.Replace(content1, "^[^\r\n]*[\r\n]*", "", RegexOptions.Singleline);
                }


                importFilePath = InData.PrependToFileName(copyOfprefix, importFilePath1);
                importFilePath = Regex.Replace(importFilePath, ".txt$", ".csv");


                // There is no header, add one
                string content3 = "";
                content3 = headerLine + "\r\n" + content2;
                InData.WriteStringToFile(importFilePath, content3, false);
            }


            return(importFilePath);
        }
Exemple #10
0
        public Dashboard()
        {
            InitializeComponent();

            InData consumo = new InData();

            DataContext = new InDataViewModel(consumo);

            total.Text   = InsureInfo.total().ToString();
            updates.Text = Notification.GetCount().ToString();
        }
Exemple #11
0
 private static void FillDsmCodeTable()
 {
     using (SqlConnection connection = new SqlConnection(InfoAspect.OutputConnectionString))
     {
         InData.Open(connection);
         _dsmCode = InData.GetTable("DsmCode"
                                    , " SELECT DsmCodeId, ConditionCode_4TR, ConditionCode_5, ConditionName, ConditionNameSource"
                                    + " FROM   DsmCode"
                                    , connection);
     }
 }
Exemple #12
0
    // Start is called before the first frame update
    void Start()
    {
        jsonPar = this;

        TextAsset asset = Resources.Load("match3jason") as TextAsset;

        if (asset != null)
        {
            inData = JsonUtility.FromJson <InData>(asset.text);
            print(inData.coloum);
        }
    }
Exemple #13
0
 public string AddRedis([FromBody] InData inData)
 {
     try
     {
         var result = _userRepository.AddRedisVal(inData.Val);
         return(result.ToString());
     }
     catch (Exception exc)
     {
         return("");
     }
 }
        // ----------------------------------------------------------------------------------------
        /// <!-- GetRow -->
        /// <summary>
        ///      Returns the row that contains the field
        /// </summary>
        /// <returns></returns>
        public DataTable GetRow(string tableName, SqlConnection connection)
        {
            string query = "SELECT *"
                           + " FROM  " + Table + " WITH(NOLOCK)"
                           + " WHERE " + Key + " = @Id";

            List <SqlParameter> parameters = new List <SqlParameter>(1);

            parameters.Add(new SqlParameter("@Id", Data4Id));
            DataTable table = InData.GetTable(tableName, query, parameters, connection);

            return(table);
        }
Exemple #15
0
        public async Task <string> AddVal([FromBody] InData inData)
        {
            try
            {
                var result = await _userRepository.AddVal(inData.Val);

                return(result.ToString());
            }
            catch (Exception exc)
            {
                return("");
            }
        }
Exemple #16
0
        // ----------------------------------------------------------------------------------------
        /// <!-- CalculateImportStatus -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="field"></param>
        /// <param name="statusErrorLog"></param>
        /// <returns></returns>
        internal static string CalculateImportStatus(DataRow field, DataTable statusErrorLog, InfoAspect aspect)
        {
            string importStatus = "Not Imported";

            try
            {
                string    fileLineNumber = field["FileLineNumber"].ToString();
                DataRow[] statusErrorRow = statusErrorLog.Select("FileLineNumber = '" + fileLineNumber + "'");


                if (statusErrorRow.Length > 0)
                {
                    string     statusErrorCode = (string)statusErrorRow[0]["Status_Error_Code"];
                    SqlBoolean isUpdate        = InData.GetSqlBoolean(field, "IsUpdate");
                    if (isUpdate)
                    {
                        if (Regex.IsMatch(statusErrorCode, "00$"))
                        {
                            throw new DataMisalignedException("Conflicting information about row update vs insert.");
                        }
                    }
                    else
                    {
                        if (Regex.IsMatch(statusErrorCode, "01$"))
                        {
                            throw new DataMisalignedException("Conflicting information about row update vs insert.");
                        }
                    }


                    if (Regex.IsMatch(statusErrorCode, "00$"))
                    {
                        importStatus = "Inserted";
                    }
                    if (Regex.IsMatch(statusErrorCode, "01$"))
                    {
                        importStatus = "Updated";
                    }
                    if (Regex.IsMatch(statusErrorCode, "35[01]$"))
                    {
                        importStatus = "Imported";
                    }
                }
            }
            catch (Exception ex) { Pause(); aspect.Rethrow(ex); }

            return(importStatus);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- ApplicationLog_Insert -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="ips">the user's ip address(es)</param>
        /// <param name="macs">a list of the user's mac addresses</param>
        /// <param name="msg">The message itself</param>
        /// <param name="gat">the Gui Action Trace (literal or symbolic)</param>
        /// <returns></returns>
        private static Guid ApplicationLog_Insert(string app, string userid, string ips, string macs, string msg, string gat)
        {
            // --------------------------------------------------------------------------
            //  Preprocess the data
            // --------------------------------------------------------------------------
            if (string.IsNullOrEmpty(_databaseLogConn))
            {
                throw new NoNullAllowedException("You Must make sure"
                                                 + " a db connection or connection name is stored in the Throw class"
                                                 + " before trying to log messages to a database!");
            }
            msg = Regex.Replace(msg, "'", "''");
            gat = Regex.Replace(gat, "'", "''");
            Guid guid = Guid.NewGuid();


            // --------------------------------------------------------------------------
            //  Build the SQL command
            // --------------------------------------------------------------------------
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "INSERT INTO CodeWhite.ApplicationLog"
                              + "        (_ID, Application, Userid, IpAddress, MacAddresses, EventMessage, GuiActionTrace)"
                              + " VALUES ('" + guid + "', '" + app + "', '" + userid + "', '" + ips + "', '" + macs + "', '" + msg + "', '" + gat + "')";
            string conn = AppConfigConnectionString(_databaseLogConn);

            cmd.Connection = new SqlConnection(conn);


            try
            {
                // ----------------------------------------------------------------------
                //  Do the actual insert
                // ----------------------------------------------------------------------
                InData.Open(cmd.Connection);
                try { cmd.ExecuteNonQuery(); }
                catch (Exception ex) { throw new DataException("query did not run properly", ex); }
                finally { InData.Close(cmd.Connection); }
            }
            catch (Exception ex) { string error = ex.Message; }


            return(guid);
        }
Exemple #18
0
        // ----------------------------------------------------------------------------------------
        /// <!-- Check -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="listFromXref"></param>
        /// <param name="label"></param>
        /// <param name="tableName"></param>
        /// <param name="keyColumn"></param>
        /// <param name="valueColumn"></param>
        /// <param name="aspect"></param>
        /// <returns></returns>
        public static string Check(NumericLookup listFromXref, string label
                                   , string tableName, string keyColumn, string valueColumn, InfoAspect aspect)
        {
            Dictionary <int, int> listFromTable = InData.GetDictionaryFrom(tableName, keyColumn, valueColumn, aspect.SecondaryConnection);
            string err   = "";
            string delim = "";

            foreach (int id in listFromXref.Values)
            {
                if (!listFromTable.ContainsKey(id))
                {
                    err  += delim + label + " Xref ID missing from " + tableName + " table: " + id;
                    delim = "\r\n";
                }
            }

            return(err);
        }
Exemple #19
0
        // ----------------------------------------------------------------------------------------
        /// <!-- DsmCode -->
        /// <summary>
        ///      Retrieves candidate dsm id's for a particular code
        /// </summary>
        /// <param name="dsmCode"></param>
        /// <returns></returns>
        public static DataRow[] DsmCode(SqlString dsmCode)
        {
            DataRow[] field = new DataRow[0];
            if (InData.DetectSqlInjection(dsmCode.ToString()))
            {
                return(field);
            }


            if (_dsmCode == null)
            {
                FillDsmCodeTable();
            }

            if (!dsmCode.IsNull)
            {
                if (field.Length == 0)
                {
                    field = _dsmCode.Select("ConditionCode_5   =    '" + dsmCode.ToString() + "' AND ConditionNameSource LIKE '%DSM%'");
                }
                if (field.Length == 0)
                {
                    field = _dsmCode.Select("ConditionCode_4TR =    '" + dsmCode.ToString() + "' AND ConditionNameSource LIKE '%DSM%'");
                }
                if (field.Length == 0)
                {
                    field = _dsmCode.Select("ConditionCode_5   =    '" + dsmCode.ToString() + "'");
                }
                if (field.Length == 0)
                {
                    field = _dsmCode.Select("ConditionCode_4TR =    '" + dsmCode.ToString() + "'");
                }
                if (field.Length == 0)
                {
                    field = _dsmCode.Select("ConditionCode_5   LIKE '%" + dsmCode.ToString() + "%'");
                }
                if (field.Length == 0)
                {
                    field = _dsmCode.Select("ConditionCode_4TR LIKE '%" + dsmCode.ToString() + "%'");
                }
            }

            return(field);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- CheckElementExists -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="exportIdColumName"></param>
        /// <param name="id"></param>
        /// <param name="aspect"></param>
        /// <returns></returns>
        protected bool CheckElementExists(string tableName, string exportIdColumName, object id, InfoAspect aspect)
        {
            bool found = false;

            if (!InData.IsNull(id))
            {
                try
                {
                    string    query = " SELECT * FROM " + tableName + " WHERE " + exportIdColumName + " = " + id.ToString(); // TODO: parameterize this
                    DataTable table = InData.GetTable(tableName, query, aspect.SecondaryConnection);
                    found = (table.Rows.Count > 0);
                }
                catch (Exception ex) { Pause(); aspect.Rethrow(ex); }
            }
            else
            {
                throw new DataException("null key not findable");
            }
            return(found);
        }
Exemple #21
0
        // ----------------------------------------------------------------------------------------
        /// <!-- CheckForError -->
        /// <summary>
        ///      Checks for an error in a numeric value field and returns an error code
        ///      if an error is found
        /// </summary>
        /// <param name="required"></param>
        /// <param name="field"></param>
        /// <param name="fieldName"></param>
        /// <param name="lo"></param>
        /// <param name="hi"></param>
        /// <param name="columnErrorCode"></param>
        /// <param name="nullErrorCode">null or blank but required</param>
        /// <param name="typeErrorCode">not a number</param>
        /// <param name="rangeErrorCode">out of range</param>
        /// <returns></returns>
        public static string CheckForError(int required, DataRow field, string fieldName, long lo, long hi
                                           , string columnErrorCode, string nullErrorCode, string typeErrorCode, string rangeErrorCode)
        {
            InfoAspect.Measuring("CheckForError(9)");

            string errorCode = string.Empty;

            if (field.Table.Columns.Contains(fieldName))                             // Check column name existence
            {
                SqlInt64 num = InData.GetSqlInt64(field, fieldName);
                if (num.IsNull)                                                      // Check numeric type validity
                {
                    string strScore = field[fieldName].ToString();
                    if (string.IsNullOrEmpty(strScore))
                    {
                        if (required >= 2)
                        {
                            errorCode = nullErrorCode;
                        }                                                            // Check required data existence
                    }
                    else
                    {
                        errorCode = typeErrorCode;
                    }
                }
                else
                {
                    if (num < lo || num > hi)
                    {
                        errorCode = rangeErrorCode;
                    }
                }                                                                    // Check data range validity
            }
            else
            {
                errorCode = columnErrorCode;
            }

            InfoAspect.Measured("CheckForError(9)");
            return(errorCode);
        }
Exemple #22
0
        // ----------------------------------------------------------------------------------------
        /// <!-- CheckForError -->
        /// <summary>
        ///      Checks for an error in a numeric code field and returns an error code
        ///      if there is an error detected, otherwise returns blank
        /// </summary>
        /// <param name="required"></param>
        /// <param name="field"></param>
        /// <param name="fieldName"></param>
        /// <param name="options"></param>
        /// <param name="columnErrorCode"></param>
        /// <param name="nullErrorCode">null or blank but required</param>
        /// <param name="typeErrorCode">not a number</param>
        /// <param name="optionErrorCode">not in list</param>
        /// <returns></returns>
        public static string CheckForError(int required, DataRow field, string fieldName, Dictionary <int, int> options
                                           , string columnErrorCode, string nullErrorCode, string typeErrorCode, string optionErrorCode)
        {
            InfoAspect.Measuring("CheckForError(8a)");

            string errorCode = string.Empty;

            if (field.Table.Columns.Contains(fieldName))                                  // Check column name existence
            {
                SqlInt32 num = InData.GetSqlInt32(field, fieldName);
                if (num.IsNull)                                                         // Check numeric type validity
                {
                    string strScore = field[fieldName].ToString();
                    if (string.IsNullOrEmpty(strScore))
                    {
                        if (required >= 2)
                        {
                            errorCode = nullErrorCode;
                        }                                 // Check required data existence
                    }
                    else
                    {
                        errorCode = typeErrorCode;
                    }
                }
                else
                {
                    if (!options.ContainsKey((int)num))
                    {
                        errorCode = optionErrorCode;
                    }
                }                                      // Check data range validity
            }
            else
            {
                errorCode = columnErrorCode;
            }

            InfoAspect.Measured("CheckForError(8a)");
            return(errorCode);
        }
        // ----------------------------------------------------------------------------------------
        /// <!-- ApplicationLog_Select -->
        /// <summary>
        ///      Pulls an item out of the database log (used for testing the class)
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public static DataTable ApplicationLog_Select(Guid guid)
        {
            // --------------------------------------------------------------------------
            //  Prepare command to read an item out of the app log in the database
            // --------------------------------------------------------------------------
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = new SqlConnection(AppConfigConnectionString(_databaseLogConn));
            cmd.CommandText = "SELECT *"
                              + " FROM ADTHL7warehouseRT.CodeWhite.vApplicationLog"
                              + " WHERE _ID = '" + guid.ToString() + "'";


            // --------------------------------------------------------------------------
            //  Read an item out of the app log in the database
            // --------------------------------------------------------------------------
            DataTable table = new DataTable();

            InData.Open(cmd.Connection);
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr != null)
            {
                try
                {
                    DataAdapter da = new DataAdapter();
                    table = new DataTable();
                    da.FillTable(table, dr);
                    //da.FillFromReader(_table, dr);
                    //dr.Dispose();
                    //dr = null;
                }
                catch { }
            }

            InData.Close(cmd.Connection);

            return(table);
        }
Exemple #24
0
        // ----------------------------------------------------------------------------------------
        /// <!-- CheckForError -->
        /// <summary>
        ///      Check in database
        /// </summary>
        /// <param name="required"></param>
        /// <param name="field"></param>
        /// <param name="fieldName"></param>
        /// <param name="dataTable"></param>
        /// <param name="column"></param>
        /// <param name="columnErrorCode"></param>
        /// <param name="nullErrorCode"></param>
        /// <param name="formatErrorCode"></param>
        /// <param name="optionErrorCode"></param>
        /// <returns></returns>
        public static string CheckForError(int required, DataRow field, string fieldName, DataTable dataTable, string column
                                           , string columnErrorCode, string nullErrorCode, string formatErrorCode, string optionErrorCode)
        {
            InfoAspect.Measuring("CheckForError(10)");

            string errorCode = string.Empty;

            if (field.Table.Columns.Contains(fieldName))                                  // Check column name existence
            {
                SqlString code = InData.GetSqlString(field, fieldName);
                if (code.IsNull || string.IsNullOrEmpty(code.ToString().Trim()))
                {
                    if (required >= 2)
                    {
                        errorCode = nullErrorCode;
                    }                                    // Check required data existence
                }
                else
                {
                    if (Regex.IsMatch(code.ToString(), "^'?[V0-9][0-9][0-9][.]?[0-9]*$", RegexOptions.IgnoreCase)) // Check data format validity
                    {
                        if (!InData.ContainsValue(dataTable, column, code))
                        {
                            errorCode = optionErrorCode;
                        }
                    }
                    else
                    {
                        errorCode = formatErrorCode;
                    }
                }
            }
            else
            {
                errorCode = columnErrorCode;
            }

            InfoAspect.Measured("CheckForError(10)");
            return(errorCode);
        }
Exemple #25
0
        // ----------------------------------------------------------------------------------------
        /// <!-- CheckForError -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="required"></param>
        /// <param name="field"></param>
        /// <param name="fieldName"></param>
        /// <param name="lookup"></param>
        /// <param name="errorCodeForColumnNameNotFound"></param>
        /// <param name="errorCodeForRequiredDataMissing"></param>
        /// <param name="errorCodeForValueIsNotAnInteger"></param>
        /// <param name="errorCodeForValueNotFoundInXref"></param>
        /// <returns></returns>
        public static string CheckForError(int required, DataRow field, string fieldName, NumericLookup lookup
                                           , string errorCodeForColumnNameNotFound, string errorCodeForRequiredDataMissing
                                           , string errorCodeForValueIsNotAnInteger, string errorCodeForValueNotFoundInXref)
        {
            string errorCode = string.Empty;

            if (field.Table.Columns.Contains(fieldName))                                  // Check column name existence
            {
                SqlInt32 num = InData.GetSqlInt32(field, fieldName);
                if (num.IsNull)                                                         // Check numeric type validity
                {
                    string strScore = field[fieldName].ToString();
                    if (string.IsNullOrEmpty(strScore))
                    {
                        if (required >= 2)
                        {
                            errorCode = errorCodeForRequiredDataMissing;
                        }                                                   // Check required data existence
                    }
                    else
                    {
                        errorCode = errorCodeForValueIsNotAnInteger;
                    }
                }
                else
                {
                    if (!lookup.ContainsKey((int)num))
                    {
                        errorCode = errorCodeForValueNotFoundInXref;
                    }
                }                                                      // Check data range validity
            }
            else
            {
                errorCode = errorCodeForColumnNameNotFound;
            }

            return(errorCode);
        }
Exemple #26
0
        // -----------------------------------------------------------------------------------------
        /// <!-- AllTests -->
        /// <summary>
        ///      B)test blew up, C)chain failure, F)test failed, I)test incomplete, S)test succeeded, N)(wrong error results)?
        /// </summary>
        /// <returns></returns>
        public string AllTests()
        {
            string result = "";

            trx = null;

            try
            {
                InData.Open(connection);
                trx = InData.Begin(connection);


                // --------------------------------------------------------------------------
                //  RichSqlCommand tests
                // --------------------------------------------------------------------------


                // --------------------------------------------------------------------------
                //  EndemeAccess tests
                // --------------------------------------------------------------------------
                EndemeAccess_HappyPath_tests();
                EndemeAccess_PrependEndeme_tests();


                result += "\r\n" + "Connected tests succeeded";
            }
            catch (Exception ex) { result += "\r\n" + "Connected tests failed with message " + ex.Message; }
            finally              { if (trx != null)
                                   {
                                       InData.Rollback(trx);
                                   }
                                   if (connection != null)
                                   {
                                       InData.Close(connection);
                                   }
            }
            return(result);
        }
Exemple #27
0
    public IEnumerator Sync(int playerID, List <UserPuzzle> unregisteredPuzzles, DateTime lastUpdate)
    {
        var outData = new OutData
        {
            PlayerID   = playerID,
            LastUpdate = lastUpdate,
            NewPuzzles = unregisteredPuzzles
                         .Select(
                p => new OutData.NewPuzzle
            {
                ID      = p.ID,
                Clue    = p.Clue,
                Content = p.Content
            })
                         .ToList()
        };

        _result = null;

        yield return(ServerController.Post <InData>("UserPuzzles/Sync", outData, data => _result = data));

        _test = DateTime.Now;
    }
    public IEnumerator Send()
    {
        CoroutinesMaster.Add("AllData", false);
        foreach (string indexer in dataType)
        {
            WWWForm form = new WWWForm();
            form.AddField("name", ServerData.GlobalUser); //добавление полей к форме отправления
            form.AddField("type", indexer);               //добавление полей к форме отправления
            UnityWebRequest www = UnityWebRequest.Post(postURL, form);
            yield return(www.SendWebRequest());           //ждем

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log("Error: " + www.error);
                yield break;
            }
            else
            {
                inData = JsonUtility.FromJson <InData>(www.downloadHandler.text);
                CoroutinesMaster.EditValue("AllData", true);
                DataSave(indexer);
            }
        }
    }
        // ----------------------------------------------------------------------------------------
        /// <!-- DeleteRow -->
        /// <summary>
        ///      Deletes the row that the field is in, if the field leads to one and only one item
        /// </summary>
        /// <param name="isUsedBy">a dictionary of tables and foreign keys where this row may be used</param>
        /// <returns></returns>
        public string DeleteRow(Dictionary <string, string> isUsedBy, SqlConnection connection)
        {
            string err = "";


            if (Data4Id != null)
            {
                SqlInt32 id = InData.GetSqlInt32(this.Data4Id);


                int useCount = 0;
                // --------------------------------------------------------------------------
                //  Test for use in another table
                // --------------------------------------------------------------------------
                if (isUsedBy != null)
                {
                    foreach (string tableName in isUsedBy.Keys)
                    {
                        string query = "SELECT COUNT(*) FROM [" + tableName + "] WHERE [" + isUsedBy[tableName] + "] = " + id;
                        useCount += (int)InData.GetSqlInt32(query, connection);
                    }
                }


                if (useCount > 0)
                {
                    err = "This record is used " + useCount + " times, you may not delete it.";
                }
                else
                {
                    // --------------------------------------------------------------------------
                    //  Build a filter from the field
                    // --------------------------------------------------------------------------
                    string fromFilter = " FROM " + this.Table + " WHERE " + Key + " = " + id;


                    // --------------------------------------------------------------------------
                    //  Check to make sure only one row will be deleted by the filter
                    // --------------------------------------------------------------------------
                    List <SqlParameter> param = new List <SqlParameter>(1);
                    param.Add(new SqlParameter("@Id", Data4Id));
                    SqlInt32 count = InData.GetSqlInt32("SELECT COUNT(*)" + fromFilter, param, connection);


                    // --------------------------------------------------------------------------
                    //  Delete the row or say why not
                    // --------------------------------------------------------------------------
                    if (count == 1)
                    {
                        SqlCommand cmd = new SqlCommand("DELETE" + fromFilter, connection);
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@Id", Data4Id);
                        cmd.ExecuteNonQuery();
                        err = "";
                        //  TODO: handle foreign key constraints
                    }
                    else
                    {
                        err = "Row not found for " + this.Table + ", id: " + id;
                    }
                }
            }
            else
            {
                err = "key empty";
            }

            return(err);
        }
Exemple #30
0
        // ------------------------------------------------------------------------------
        //  Property-like methods (property wrapper)
        // ------------------------------------------------------------------------------
        public static SqlInt32 DsmCode_Lookup(SqlString dsmCode)
        {
            if (_dsmCode == null)
            {
                FillDsmCodeTable();
            }


            // ----------------------------------------------------------------------
            //  Bail out if blank
            // ----------------------------------------------------------------------
            if (dsmCode.IsNull)
            {
                return(SqlInt32.Null);
            }
            if (string.IsNullOrEmpty(dsmCode.ToString().Trim()))
            {
                return(SqlInt32.Null);
            }


            // ----------------------------------------------------------------------
            //  Find matches
            // ----------------------------------------------------------------------
            string   code1 = Regex.Replace(dsmCode.ToString().Trim(), "'", "");
            SqlInt32 id    = SqlInt32.Null;

            DataRow[] list = null;


            string code2 = "JeSuS";
            string code3 = "JeSuS";

            switch (code1.Length)
            {
            case 3: code2 = code1 + ".0";                   code3 = code1 + ".00";                   break;

            case 6: code2 = Regex.Replace(code1, "0$", ""); code3 = Regex.Replace(code1, "00$", ""); break;

            default: code2 = code1 + "0";                    code3 = Regex.Replace(code1, "0$", ""); break;
            }


            // ----------------------------------------------------------------------
            //  Extract id
            // ----------------------------------------------------------------------
            if (id.IsNull)
            {
                list = _dsmCode.Select("ConditionCode_4TR = '" + code1 + "'" + " OR ConditionCode_5 = '" + code1 + "'"); if (list.Length > 0)
                {
                    id = InData.GetSqlInt32(list[0], "DsmCodeId");
                }
            }
            if (id.IsNull)
            {
                list = _dsmCode.Select("ConditionCode_4TR = '" + code2 + "'" + " OR ConditionCode_5 = '" + code2 + "'"); if (list.Length > 0)
                {
                    id = InData.GetSqlInt32(list[0], "DsmCodeId");
                }
            }
            if (id.IsNull)
            {
                list = _dsmCode.Select("ConditionCode_4TR = '" + code3 + "'" + " OR ConditionCode_5 = '" + code3 + "'"); if (list.Length > 0)
                {
                    id = InData.GetSqlInt32(list[0], "DsmCodeId");
                }
            }
            if (id.IsNull)
            {
                list = _dsmCode.Select("ConditionCode_4TR = '''" + code1 + "'" + " OR ConditionCode_5 = '''" + code1 + "'"); if (list.Length > 0)
                {
                    id = InData.GetSqlInt32(list[0], "DsmCodeId");
                }
            }
            if (id.IsNull)
            {
                list = _dsmCode.Select("ConditionCode_4TR = '''" + code2 + "'" + " OR ConditionCode_5 = '''" + code2 + "'"); if (list.Length > 0)
                {
                    id = InData.GetSqlInt32(list[0], "DsmCodeId");
                }
            }
            if (id.IsNull)
            {
                list = _dsmCode.Select("ConditionCode_4TR = '''" + code3 + "'" + " OR ConditionCode_5 = '''" + code3 + "'"); if (list.Length > 0)
                {
                    id = InData.GetSqlInt32(list[0], "DsmCodeId");
                }
            }
            if (id.IsNull)
            {
                Pause();
            }

            return(id);
        }