示例#1
0
        protected void OnAddItemClick(object sender, EventArgs e)
        {
            TFlexObjSynchDialog dialog = new TFlexObjSynchDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var obj = _repoObjSynchView.GetById(dialog.Id);
                AddRow(obj);
            }
        }
示例#2
0
        public async Task <IEnumerable <ItemDTO> > GetByView(Guid viewID)
        {
            var view = await _viewRepository.GetById(viewID);

            var categoryIds = view.ViewCategories
                              .Select(vc => vc.CategoryId);

            return((await _itemRepository.GetByCategories(categoryIds))
                   .Select(ItemMapper.Map));
        }
示例#3
0
        private async Task <View> GetById(Guid id)
        {
            var view = await _repository.GetById(id);

            if (view == null)
            {
                throw new KeyNotFoundException("No such element.");
            }

            return(view);
        }
示例#4
0
        public async Task <IEnumerable <SchedulerResourceDTO> > GetByViewId(Guid viewId)
        {
            var categoryIds = (await _viewRepository.GetById(viewId))
                              ?.ViewCategories.Select(viewCategory => viewCategory.CategoryId).ToList();

            if (categoryIds == null || !categoryIds.Any())
            {
                return(null);
            }

            var viewCategories = _categoryRepository.GetByIds(categoryIds);

            var viewItems = viewCategories
                            .SelectMany(vCategory => vCategory.Items ?? new List <Item>())
                            .ToList();

            return(viewCategories
                   .Select(SchedulerResourceMapper.Map)
                   .Concat(viewItems.Select(SchedulerResourceMapper.Map)));
        }
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (dialogType == DialogType.Add)
            {
                SEPO_TFLEX_OBJ_SYNCH synch = new SEPO_TFLEX_OBJ_SYNCH
                {
                    TFLEX_SECTION = _repoSections.GetById(sectionBox.SelectedValue)
                };

                if ((int)signDocBox.SelectedValue != 0)
                {
                    synch.TFLEX_DOCSIGN = _repoSignDocs.GetById(signDocBox.SelectedValue);
                }

                synch.OMP_BOTYPE  = (int)boTypeBox.SelectedValue;
                synch.OMP_BOSTATE = (int)boStateBox.SelectedValue;

                if ((int)groupFileBox.SelectedValue != 0)
                {
                    synch.OMP_FILEGROUP = (int)groupFileBox.SelectedValue;
                }

                synch.OMP_SECTION = (int)ompSectionBox.SelectedValue;

                if (paramDependenceBox.Checked)
                {
                    synch.PARAM_DEPENDENCE = 1;
                    synch.ID_PARAM         = _repoObjParams.GetById(paramBox.SelectedValue);
                    synch.EXPRESSION       = paramExpressionBox.Text;
                }
                else
                {
                    synch.PARAM_DEPENDENCE = 0;
                    synch.ID_PARAM         = null;
                    synch.EXPRESSION       = null;
                }

                if ((int)typeObjBox.SelectedValue != 0)
                {
                    synch.ID_SECTION_TYPE = _repoSectionTypes.GetById(typeObjBox.SelectedValue);
                }

                using (var transaction = new UnitOfWork())
                {
                    try
                    {
                        _repoObjSynch.Create(synch);

                        transaction.Commit();

                        Id           = synch.ID;
                        DialogResult = DialogResult.OK;
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }
            else
            {
                SEPO_TFLEX_OBJ_SYNCH item = _repoObjSynch.GetQuery().Where(x => x.ID == Id).FirstOrDefault();

                item.TFLEX_SECTION = _repoSections.GetById(sectionBox.SelectedValue);

                if ((int)signDocBox.SelectedValue != 0)
                {
                    item.TFLEX_DOCSIGN = _repoSignDocs.GetById(signDocBox.SelectedValue);
                }
                else
                {
                    item.TFLEX_DOCSIGN = null;
                }

                item.OMP_BOTYPE  = (int)boTypeBox.SelectedValue;
                item.OMP_BOSTATE = (int)boStateBox.SelectedValue;

                if ((int)groupFileBox.SelectedValue != 0)
                {
                    item.OMP_FILEGROUP = (int)groupFileBox.SelectedValue;
                }
                else
                {
                    item.OMP_FILEGROUP = null;
                }

                item.OMP_SECTION = (int)ompSectionBox.SelectedValue;

                if (paramDependenceBox.Checked)
                {
                    item.PARAM_DEPENDENCE = 1;
                    item.ID_PARAM         = _repoObjParams.GetById(paramBox.SelectedValue);
                    item.EXPRESSION       = paramExpressionBox.Text;
                }
                else
                {
                    item.PARAM_DEPENDENCE = 0;
                    item.ID_PARAM         = null;
                    item.EXPRESSION       = null;
                }

                if ((int)typeObjBox.SelectedValue != 0)
                {
                    item.ID_SECTION_TYPE = _repoSectionTypes.GetById(typeObjBox.SelectedValue);
                }
                else
                {
                    item.ID_SECTION_TYPE = null;
                }

                using (var transaction = new UnitOfWork())
                {
                    try
                    {
                        _repoObjSynch.Update(item);

                        transaction.Commit();

                        DialogResult = DialogResult.OK;
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }
        }
示例#6
0
        private void OnRun(object sender, DoWorkEventArgs e)
        {
            int counter = 0;

            using (var transaction = new UnitOfWork())
            {
                try
                {
                    var docs = _repoDocParam
                               .GetQuery()
                               .Where(x => x.FILENAME.ToLower().EndsWith(".grb"));

                    foreach (var docParam in docs)
                    {
                        if (backWorker.CancellationPending)
                        {
                            transaction.Rollback();

                            e.Cancel = true;
                            return;
                        }

                        DOCUMENTS_PARTS docPart = null;

                        try
                        {
                            docPart = _repoDoc.GetById(docParam.CODE);
                        }
                        catch (Exception)
                        {
                            continue;
                        }

                        byte[] docContent = { };

                        if (docPart.COMPRESSED == 1)
                        {
                            Stream inStream = new MemoryStream(docPart.DATA);
                            inStream.Seek(8, SeekOrigin.Begin);

                            Stream outStream = new MemoryStream();

                            BZip2.Decompress(inStream, outStream, false);
                            outStream.Seek(0, SeekOrigin.Begin);

                            docContent = new byte[outStream.Length];
                            outStream.Read(docContent, 0, (int)outStream.Length);
                        }
                        else
                        {
                            docContent = docPart.DATA;
                        }

                        if (docContent == null)
                        {
                            continue;
                        }

                        SHA1   s    = new SHA1CryptoServiceProvider();
                        byte[] hash = s.ComputeHash(docContent);

                        string hash1 = (System.BitConverter.ToString(hash)).Replace("-", "").ToLower();

                        docParam.HASH_ALG = 1;
                        docParam.HASH     = hash1;

                        _repoDocParam.Update(docParam);
                        backWorker.ReportProgress(++counter);
                    }

                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }