Esempio n. 1
0
        public OLEConnection(string PathToDatabase, V77Servers ServerType, bool Exclusive, string User, string Password)
        {
            FPathToDatabase = PathToDatabase;
            FUser           = User;
            FPassword       = Password;
            FExclusive      = Exclusive;
            if (!Directory.Exists(PathToDatabase) && (PathToDatabase != ""))
            {
                throw new OLE1C77Exception("Сбой соединения !!! Каталог - " + PathToDatabase + "  не существует !!!");
            }
            V77OLE        = Type.GetTypeFromProgID(Enum.Format(typeof(V77Servers), ServerType, "G") + ".Application");
            Handle        = Activator.CreateInstance(V77OLE);
            GlobalContext = new OLE(this, Handle);
            OLE RMTrade = Global.Method("RMTrade");

            string ParamStr = "/D" + PathToDatabase;

            if (Exclusive)
            {
                ParamStr = ParamStr + " /M";
            }
            if (User != "")
            {
                ParamStr = ParamStr + " /N" + User;
            }
            if (Password != "")
            {
                ParamStr = ParamStr + " /P" + Password;
            }

            if (!(bool)Global.Method("Initialize", RMTrade, ParamStr, "").ToObject())
            {
                throw new OLE1C77Exception("Сбой соединения !!! Вероятней всего программа запущена монопольно или требует переиндексации !!!");
            }
        }
Esempio n. 2
0
 public void Dispose()
 {
     V77OLE        = null;
     GlobalContext = null;
     Handle        = null;
     GC.SuppressFinalize(this);
     GC.Collect();
 }
Esempio n. 3
0
 public Reference1C77(OLEConnection Connection, string RefName)
 {
     Reference = Connection.Global.CreateObject("—правочник." + RefName);
     Reference.Method("¬ыбратьЁлементы");
     FCurrentRecord = -1;
     RecRef         = new List <RecordReference1C77>();
     while (Reference.Method("ѕолучитьЁлемент").ToBool())
     {
         FCurrentRecord++;
         doCreateRecord();
         doCopyRecord();
         RecRef.Add(RecRefType);
     }
     if (FCurrentRecord >= 0)
     {
         FCurrentRecord = 0;
     }
 }
Esempio n. 4
0
        public OLEConnection(string PathToDatabase, V77Servers ServerType, bool Exclusive, string User, string Password)
        {
            FPathToDatabase = PathToDatabase;
            FUser           = User;
            FPassword       = Password;
            FExclusive      = Exclusive;
            if (!Directory.Exists(PathToDatabase) && (PathToDatabase != ""))
            {
                throw new OLE1C77Exception("Сбой соединения !!! Каталог - " + PathToDatabase + "  не существует !!!");
            }
            V77OLE        = Type.GetTypeFromProgID(Enum.Format(typeof(V77Servers), ServerType, "G") + ".Application");
            Handle        = Activator.CreateInstance(V77OLE);
            GlobalContext = new OLE(this, Handle);
            OLE RMTrade = Global.Method("RMTrade");

            string ParamStr = "/D" + PathToDatabase;

            if (Exclusive)
            {
                ParamStr = ParamStr + " /M";
            }
            if (User != "")
            {
                ParamStr = ParamStr + " /N" + User;
            }
            if (Password != "")
            {
                ParamStr = ParamStr + " /P" + Password;
            }

            if (!(bool)Global.Method("Initialize", RMTrade, ParamStr, "").ToObject())
            {
                GlobalContext = null;
                Handle        = null;
                V77OLE        = null;
                throw new OLE1C77Exception("Сбой соединения !!! Вероятней всего программа запущена монопольно или требует переиндексации !!!");
            }

            ntics_CommonAllConfig conf = new ntics_CommonAllConfig();

            FirmReference = Global.CreateObject("Справочник.Фирмы");
            FirmReference.Method("ВыбратьЭлементы");
            while (FirmReference.Method("ПолучитьЭлемент").ToBool())
            {
                if (FirmReference.Method("DeleteMark").ToBool())
                {
                    continue;
                }
                if (FirmReference.Property("ЕДРПОУ").ToString().Trim() == conf.ЕДРПОУ)
                {
                    FirmReference = FirmReference.Method("CurrentItem");
                    return;
                }
            }

            string s = Global.EvalExpr("SystemCaption()").ToString();

            FirmReference = null;
            GlobalContext = null;
            Handle        = null;
            V77OLE        = null;
            throw new OLE1C77Exception("Программа не зарегистрирована для даной базы: " + s);
        }