Пример #1
0
        protected override void DoWorkCore(LongOperation longOperation)
        {
            Random       random = new Random();
            IObjectSpace updatingObjectSpace = Application.CreateObjectSpace(typeof(FullyAuditedBatchCreationObject));
            IList <FullyAuditedBatchCreationObject> collection = updatingObjectSpace.GetObjects <FullyAuditedBatchCreationObject>();
            int index = 0;

            try {
                foreach (object currentObject in collection)
                {
                    ((FullyAuditedBatchCreationObject)currentObject).InitializeObject(collection.Count - index);
                    ((FullyAuditedBatchCreationObject)currentObject).Save();
                    if (index % 50 == 0)
                    {
                        updatingObjectSpace.CommitChanges();
                    }
                    if (longOperation.Status == LongOperationStatus.InProgress)
                    {
                        longOperation.RaiseProgressChanged((int)((++index * 100) / collection.Count), "Modifying objects...");
                    }
                    if (longOperation.Status == LongOperationStatus.Cancelling)
                    {
                        return;
                    }
                }
            }
            catch (LongOperationTerminateException) {
                longOperation.CancelAsync();
            }
            updatingObjectSpace.CommitChanges();
        }
Пример #2
0
        protected override void DoWorkCore(LongOperation longOperation)
        {
            int initialIndex = GetInitialIndex();
            ObjectPoolCreationOptionsEventArgs args = new ObjectPoolCreationOptionsEventArgs(defaultDemoObjectsCount, defaultDemoObjectsCommitInterval);
            BatchCreationOptionsAttribute      creationOptionsAttribute = ((DevExpress.ExpressApp.ListView)View).ObjectTypeInfo.FindAttribute <BatchCreationOptionsAttribute>();

            if (creationOptionsAttribute != null)
            {
                if (creationOptionsAttribute.ObjectsCount.HasValue)
                {
                    args.DemoObjectsCount = creationOptionsAttribute.ObjectsCount.Value;
                }
                if (creationOptionsAttribute.CommitInterval.HasValue)
                {
                    args.DemoObjectsCommitInterval = creationOptionsAttribute.CommitInterval.Value;
                }
            }
            if (CustomizeObjectPoolCreationOptions != null)
            {
                CustomizeObjectPoolCreationOptions(this, args);
            }
            IObjectSpace objectSpace = CreateUpdatingSession();

            try {
                Type objectType = ((DevExpress.ExpressApp.ListView)View).ObjectTypeInfo.Type;
                for (int index = 0; index < args.DemoObjectsCount; index++)
                {
                    try {
                        if (index % args.DemoObjectsCommitInterval == 0)
                        {
                            CommitUpdatingSession(objectSpace);
                        }

                        IObjectPropertiesInitializer newObject = objectSpace.CreateObject(objectType) as IObjectPropertiesInitializer;
                        newObject.InitializeObject(index + initialIndex);

                        if (longOperation.Status == LongOperationStatus.InProgress)
                        {
                            longOperation.RaiseProgressChanged((int)((index * 100) / args.DemoObjectsCount), string.Format(progressMessageTemplate, index + 1, args.DemoObjectsCount));
                        }
                        if (longOperation.Status == LongOperationStatus.Cancelling)
                        {
                            return;
                        }
                    }
                    catch (LongOperationTerminateException) {
                        longOperation.CancelAsync();
                        break;
                    }
                }
            }
            finally {
                CommitUpdatingSession(objectSpace);
                DisposeUpdatingSession(objectSpace);
            }
        }
        protected void DoWorkCore(LongOperation longOperation)
        {
            //Random random = new Random();
            IObjectSpace os = Application.CreateObjectSpace();
            //            IList<FullyAuditedBatchCreationObject> collection = updatingObjectSpace.GetObjects<FullyAuditedBatchCreationObject>();
            int index = 0;

            try {
                XWZKXCOA            short_orders = SynIBSOrderExchangeLogic.Catalog(os);
                IList <fmCOrderExt> orders       = os.GetObjects <fmCOrderExt>();
                IList <fmСOrderAnalitycAccouterType> acc_types = os.GetObjects <fmСOrderAnalitycAccouterType>();
                IList <fmCFAAccount> accounts = os.GetObjects <fmCFAAccount>(new BinaryOperator("AccountSystem.Code", "1000"));
                foreach (XWZKXCOAZKLIST short_order in short_orders.ZKLIST)
                {
                    fmCOrderExt order = orders.First(item => item.Code == short_order.ZKCODE);
                    if (order == null)
                    {
                        Trace.TraceWarning("IBSOrderSyncAll: Order >" + short_order.ZKCODE + "< not found");
                        continue;
                    }
                    if (!short_order.ZKISCLOSED)
                    {
                        if (order.Status == fmIOrderStatus.Project || order.Status == fmIOrderStatus.FinOpened)
                        {
                            order.Status   = fmIOrderStatus.Opened;
                            order.IsClosed = false;
                        }
                    }
                    else
                    {
                        if (order.Status == fmIOrderStatus.Project || order.Status == fmIOrderStatus.FinClosed)
                        {
                            order.Status   = fmIOrderStatus.Closed;
                            order.IsClosed = true;
                        }
                    }
                    if (!String.IsNullOrEmpty(short_order.ZKACCOUNTTYPE))
                    {
                        order.AnalitycAccouterType = acc_types.FirstOrDefault(x => x.Code == short_order.ZKACCOUNTTYPE);
                    }
                    if (!String.IsNullOrEmpty(short_order.ZKACCOUNTCODE))
                    {
                        order.BuhAccount = accounts.FirstOrDefault(x => x.BuhCode == short_order.ZKACCOUNTCODE);
                    }
                    os.CommitChanges();
                    //
                    if (longOperation.Status == LongOperationStatus.InProgress)
                    {
                        longOperation.RaiseProgressChanged((int)((++index * 100) / short_orders.ZKLIST.Count), "Обновляем заказ " + index.ToString() + " из " + short_orders.ZKLIST.Count.ToString());
                    }
                    if (longOperation.Status == LongOperationStatus.Cancelling)
                    {
                        return;
                    }
                }
            }
            catch (LongOperationTerminateException) {
                os.Rollback();
                longOperation.CancelAsync();
            }
            catch (Exception e) {
                longOperation.TerminateAsync();
                throw e;
            }
            //os.Rollback();
        }
Пример #4
0
        protected void StaffListSyncProcess(LongOperation longOperation)
        {
            StaffSyncLongOperation operation = (StaffSyncLongOperation)longOperation;
            XWTBXLIA msg_in = new XWTBXLIA();

            //Random random = new Random();
            try {
                //            IList<FullyAuditedBatchCreationObject> collection = updatingObjectSpace.GetObjects<FullyAuditedBatchCreationObject>();
                int current = 0;
                int count   = 0;
                //Assert.AreEqual(lres.VOLIST.Count, 20);
                foreach (var item in operation.StaffList.TBLIST)
                {
                    //                System.Console.WriteLine(item.TBCODE + " " + item.TBBUHCODE + " " + item.TBDPCODE);
                    count++;
                    current++;
                    msg_in.TBBUHCODE.Add(item.TBBUHCODE);
                    if (count >= 100 || current >= operation.StaffList.TBLIST.Count)
                    {
                        if (longOperation.Status == LongOperationStatus.Cancelling)
                        {
                            return;
                        }
                        msg_in.CMD = "LIST";
                        XWTBXLOA list_res = operation.SyncService.XWTBXL0N(msg_in);
                        using (IObjectSpace os = Application.CreateObjectSpace()) {
                            foreach (var item2 in list_res.TBLIST)
                            {
//                                System.Console.WriteLine(item2.TBCODE + " " + item2.TBLASTNAME + " " + item2.TBFIRSTNAME + " " + item2.TBMIDDLENAME + " " + item2.TBDPCODE);
                                if (item2.TBBUHCODE == 13951)
                                {
                                    System.Console.WriteLine("Sync A1 source: " + item2.TBBUHCODE + " dep: " + item2.TBDPCODE);
                                }
                                hrmStaff         staff;
                                IList <hrmStaff> staffs = os.GetObjects <hrmStaff>(new BinaryOperator("BuhCode", item2.TBBUHCODE.ToString(), BinaryOperatorType.Equal));
                                if (staffs.Count > 1 || staffs.Count < 0)
                                {
                                    continue;
                                }
                                if (staffs.Count == 1)
                                {
                                    staff = staffs[0];
                                }
                                else
                                {
                                    staff = os.CreateObject <hrmStaff>();
                                }
                                if (item2.TBBUHCODE == 13951)
                                {
                                    System.Console.WriteLine("Sync ERM before: " + staff.BuhCode + " dep: " + staff.Department != null ? staff.Department.Code : String.Empty);
                                }
                                //staff.Code = item2.TBCODE;
                                staff.BuhCode    = item2.TBBUHCODE.ToString();
                                staff.FirstName  = item2.TBFIRSTNAME;
                                staff.MiddleName = item2.TBMIDDLENAME;
                                staff.LastName   = item2.TBLASTNAME;
                                if (item2.TBSEX == "Ж")
                                {
                                    staff.Sex = CRM.Party.crmPhysicalPersonSex.FEMALE;
                                }
                                else
                                {
                                    staff.Sex = CRM.Party.crmPhysicalPersonSex.MALE;
                                }
                                //
                                //staff.DateBegin = item2.TBDTBEGIN;

                                IList <hrmDepartment> deps = os.GetObjects <hrmDepartment>(
                                    new BinaryOperator("BuhCode", item2.TBDPCODE.ToString(), BinaryOperatorType.Equal));
                                if (deps.Count > 0)
                                {
                                    staff.Department = deps[0];
                                }
                                //                                staff.IsClosed = item2.TBISCLOSED;
                                if (item2.TBBUHCODE == 13951)
                                {
                                    System.Console.WriteLine("Sync ERM after: " + staff.BuhCode + " dep: " + staff.Department != null ? staff.Department.Code : String.Empty);
                                }
                            }
                            os.CommitChanges();
                        }
                        if (longOperation.Status == LongOperationStatus.InProgress)
                        {
                            longOperation.RaiseProgressChanged(
                                (int)((current * 100) / operation.StaffList.TBLIST.Count),
                                "Update Staff " + current.ToString() + " from " + operation.StaffList.TBLIST.Count.ToString());
                            //longOperation.RaiseProgressChanged((int)((++index * 100) / dpl.Count), "Update Departnent " + index.ToString() + " from " + msg_out.DPLIST.Count.ToString());
                        }
                        count  = 0;
                        msg_in = new XWTBXLIA();
                    }
                }
            }
            catch (LongOperationTerminateException) {
                longOperation.CancelAsync();
            }
            catch (Exception e) {
                longOperation.TerminateAsync();
                throw e;
            }
        }
Пример #5
0
        protected void DoWorkCore(LongOperation longOperation)
        {
            //Random random = new Random();
            IObjectSpace os = Application.CreateObjectSpace();
            //            IList<FullyAuditedBatchCreationObject> collection = updatingObjectSpace.GetObjects<FullyAuditedBatchCreationObject>();
            int index = 0;

            try {
                HTTPSyncService syncservice = new HTTPSyncService(ConfigurationManager.AppSettings["IBS.SyncService"]);
                XWDPXLIA        msg_in      = new XWDPXLIA();
                msg_in.CMD = "LIST";
                XWDPXLOA msg_out = syncservice.XWDPXL0N(msg_in);
                foreach (XWDPXLOADPLIST dps in msg_out.DPLIST)
                {
                    hrmDepartment         dp;
                    IList <hrmDepartment> dpl = os.GetObjects <hrmDepartment>(new BinaryOperator("BuhCode", dps.DPBUHCODE.ToString(), BinaryOperatorType.Equal));
                    if (dpl.Count > 0)
                    {
                        dp = dpl[0];
                    }
                    else
                    {
                        dp = os.CreateObject <hrmDepartment>();
                    }
                    if (dp.Code != dps.DPCODE)
                    {
                        dp.Code = dps.DPCODE;
                    }
                    if (dp.BuhCode != dps.DPBUHCODE.ToString())
                    {
                        dp.BuhCode = dps.DPBUHCODE.ToString();
                    }
                    if (dp.Name != dps.DPNAME)
                    {
                        dp.Name = dps.DPNAME;
                    }
                    if (dp.IsClosed != dps.DPISCLOSED)
                    {
                        dp.IsClosed = dps.DPISCLOSED;
                    }
                    os.CommitChanges();
                    //
                    if (longOperation.Status == LongOperationStatus.InProgress)
                    {
                        longOperation.RaiseProgressChanged((int)((++index * 100) / msg_out.DPLIST.Count), "Update Departnent " + index.ToString() + " from " + msg_out.DPLIST.Count.ToString());
//                        longOperation.RaiseProgressChanged((int)((++index * 100) / dpl.Count), "Update Departnent " + index.ToString() + " from " + msg_out.DPLIST.Count.ToString());
                    }
                    if (longOperation.Status == LongOperationStatus.Cancelling)
                    {
                        return;
                    }
                }
            }
            catch (LongOperationTerminateException) {
                os.Rollback();
                longOperation.CancelAsync();
            }
            catch (Exception e) {
                longOperation.TerminateAsync();
                throw e;
            }
            //os.Rollback();
        }