コード例 #1
0
        public byte[] Load(string dalName)
        {
            Type ty = this.GetType();

            System.Reflection.MethodInfo mi = ty.GetMethod("Get" + dalName);
            atDAL.ObjectDAL od = (atDAL.ObjectDAL)mi.Invoke(this, null);

            return(od.LoadByte());
        }
コード例 #2
0
 /// <summary>
 /// Recreates DAL object if it has expired on server
 /// Only used when DAL is remoted
 /// </summary>
 public void RecoverDAL()
 {
     if (DALName == "")
     {
         myODAL = MyMngr.AppMan.myDALClient.RecoverDAL(myDT.TableName);
     }
     else
     {
         myODAL = MyMngr.AppMan.myDALClient.RecoverDAL(DALName);
     }
 }
コード例 #3
0
        public DataSet Update(List <string> dtList, DataSet dsIn)
        {
            FixTZDSIssue(dsIn);
            string curTblNm = "";
            int    retries  = 3;

            while (retries > 0)
            {
                try
                {
                    //deletes
                    dtList.Reverse();
                    foreach (string dtName in dtList)
                    {
                        string[] bits = dtName.Split(new Char[] { '.' });
                        curTblNm = bits[0];
                        //get a dal for the table
                        Type   ty  = this.GetType();
                        string dal = bits[0];
                        if (bits.Length > 1)
                        {
                            dal = bits[1];
                        }

                        System.Reflection.MethodInfo mi = ty.GetMethod("Get" + dal);
                        atDAL.ObjectDAL od = (atDAL.ObjectDAL)mi.Invoke(this, null);

                        DataTable dtIn  = dsIn.Tables[bits[0]];
                        DataTable dtDEL = dtIn.GetChanges(DataRowState.Deleted);
                        if (dtDEL != null)
                        {
                            od.Update(dtDEL);
                        }
                    }

                    //inserts and updates
                    dtList.Reverse();
                    foreach (string dtName in dtList)
                    {
                        string[] bits = dtName.Split(new Char[] { '.' });
                        curTblNm = bits[0];
                        //get a dal for the table
                        Type   ty  = this.GetType();
                        string dal = bits[0];
                        if (bits.Length > 1)
                        {
                            dal = bits[1];
                        }

                        System.Reflection.MethodInfo mi = ty.GetMethod("Get" + dal);
                        atDAL.ObjectDAL od = (atDAL.ObjectDAL)mi.Invoke(this, null);

                        DataTable dtIn = dsIn.Tables[bits[0]];

                        DataTable dtUPD = dtIn.GetChanges(DataRowState.Modified | DataRowState.Added);
                        if (dtUPD != null)
                        {
                            od.Update(dtUPD);
                            dsIn.Tables.Remove(bits[0]);
                            dsIn.Tables.Add(dtUPD);
                        }
                    }

                    Commit();

                    retries = 0;
                    // return CompressData(dsIn);
                }
                catch (SqlException sqlx)
                {
                    if (sqlx.Number == 1205 && retries > 1)
                    {
                        retries--;
                        System.Threading.Thread.Sleep(500);
                    }
                    else
                    {
                        string msg = "Could not update table: {0}";
                        try
                        {
                            Rollback();
                        }
                        catch (Exception x)
                        {
                            msg += ": Rollback " + x.Message;
                        }

                        throw new ApplicationException(String.Format(msg, curTblNm), sqlx);
                    }
                }
                catch (Exception xr)
                {
                    string msg = "Could not update table: {0}";
                    try
                    {
                        Rollback();
                    }
                    catch (Exception x)
                    {
                        msg += ": Rollback " + x.Message;
                    }
                    throw new ApplicationException(String.Format(msg, curTblNm), xr);
                }
            }
            return(dsIn);
        }