예제 #1
0
        private void Insert(EmRefundAddress address)
        {
            try
            {
                InsertResult result = GlobalCache.EMallServerProxy.InsertEmRefundAddress(address);
                switch (result)
                {
                case InsertResult.Success:
                    // GlobalMessageBox.Show("保存成功!");
                    Display();
                    break;

                case InsertResult.Error:
                    GlobalMessageBox.Show("内部错误!");
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }
예제 #2
0
        /// <summary>
        /// 新增員工身分資料
        /// </summary>
        public bool InsertEmployeeRoleData(RoleParams param)
        {
            InsertResult insResult = new InsertResult()
            {
                IsSuccess = false
            };

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                EmployeeRole entity = new EmployeeRole()
                {
                    RoleName        = param.RoleName,
                    RoleDisplayName = param.RoleDisplayName,
                    SortNo          = param.SortNo,
                    PostAccount     = param.PostAccount,
                    PostDate        = DateTime.Now
                };

                insResult = empAuthDao.InsertEmployeeRoleData(entity, param.CopyPrivilegeFromRoleName);
                dbErrMsg  = empAuthDao.GetErrMsg();

                if (insResult.IsSuccess)
                {
                    param.RoleId = entity.RoleId;
                }
                else if (empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.HasRoleBeenUsed = true;
                }
            }

            return(insResult.IsSuccess);
        }
예제 #3
0
        /// <summary>
        /// 新增部門資料
        /// </summary>
        public bool InsertDepartmentData(DeptParams param)
        {
            InsertResult insResult = new InsertResult()
            {
                IsSuccess = false
            };

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                Department entity = new Department()
                {
                    DeptName    = param.DeptName,
                    SortNo      = param.SortNo,
                    PostAccount = param.PostAccount,
                    PostDate    = DateTime.Now
                };

                insResult = empAuthDao.InsertDepartmentData(entity);
                dbErrMsg  = empAuthDao.GetErrMsg();

                if (insResult.IsSuccess)
                {
                    param.DeptId = (int)insResult.NewId;
                }
                else if (empAuthDao.GetSqlErrNumber() == 50000 && empAuthDao.GetSqlErrState() == 2)
                {
                    param.HasDeptNameBeenUsed = true;
                }
            }

            return(insResult.IsSuccess);
        }
        public void Insert2()
        {
            Dictionary <Guid, DateTime> Read = new Dictionary <Guid, DateTime>()
            {
                { Guid.Parse("6B9F4B43-5F78-E811-80C7-000C29DADC00"), DateTime.UtcNow }
            };

            MasterSettings.SetProperties(new Dictionary <string, object>()
            {
                { "CreatedBy", Guid.Parse("FC09E7EE-5E78-E811-80C7-000C29DADC00") }
            }, MasterSettings.Triggers.BeforeInsert);
            //MasterSettings.SetProperties(new Dictionary<string, object>() { { "CreatedBy", Guid.Parse("6B9F4B43-5F78-E811-80C7-000C29DADC00") } }, MasterSettings.Triggers.AfterInsert);
            Message message = new Message()
            {
                Text    = $"Test message # {DateTime.UtcNow.ToShortTimeString()}",
                Client  = 1,
                Caterer = 1,
                Read    = Read
            };

            InsertResult <Message> result = MessageRepository.Insert(message);

            Console.WriteLine($"Success:{result.Success}\nCollectionId:{result.CollectionId}\nInserted:\n{JToken.Parse(JsonConvert.SerializeObject(result.Result)).ToString(Formatting.Indented)}");

            Assert.IsNotNull(result.Result);
            Assert.IsInstanceOfType(result.Result, typeof(Message));
        }
예제 #5
0
        InsertResult <JSONDocument> IDocumentStore.InsertDocument(InsertOperation operation)
        {
            UsageStats stats = new UsageStats();

            stats.BeginSample();

            InsertResult <JSONDocument> result = new InsertResult <JSONDocument>();
            CacheItem citem = new CacheItem();

            citem.Document = operation.Document;
            citem.Flag.SetBit(BitsetConstants.DocumentDirty);
            citem.Flag.SetBit(BitsetConstants.MetaDataDirty);
            citem.Flag.UnsetBit(BitsetConstants.MarkedForDeletion);

            CacheInsert(operation.RowId, citem, false);
            _indexManager.AddToIndex(operation.RowId, operation.Document, operation.OperationId);

            _parent.MetadataIndex.Add(new DocumentKey(operation.Document.Key), operation.RowId, operation.Document, operation.Context);

            PersistenceOperation persistenceOperation = new PersistenceInsertOperation(operation.OperationId, _parent.Name, operation.RowId, citem, operation.Context);

            AddToPersistenceDictionary(persistenceOperation);
            result.RowId = operation.RowId;

            if (_statsCollector != null)
            {
                stats.EndSample();
                _statsCollector.IncrementStatsValue(StatisticsType.AvgInsertTime, stats.Current);
                _statsCollector.IncrementStatsValue(StatisticsType.InsertsPerSec);
            }
            return(result);
        }
예제 #6
0
        public void insertCellThread(int column, string currentUser)
        {
            try
            {
                InsertResult insertResult = client.Insert(column, currentUser, gameId);
                GameBoard[insertResult.Row_index, column] = PlayerColor;
                currentColumn = column;
                Application.Current.Dispatcher.Invoke(new Action(() => { DrawCircle(PlayerColor, column); }));

                if (insertResult.Move_result == MOVE_RESULT.Win)
                {
                    MessageBox.Show("Congrats, you won");
                    Closed_from_gui = true;
                    Application.Current.Dispatcher.Invoke(new Action(() => { this.Close(); }));
                }
                else if (insertResult.Move_result == MOVE_RESULT.Draw)
                {
                    MessageBox.Show("Game ended with Draw");
                    Closed_from_gui = true;
                    Application.Current.Dispatcher.Invoke(new Action(() => { this.Close(); }));
                }
            }
            catch (FaultException <GameNotFoundFault> ex)
            {
                MessageBox.Show(ex.Detail.Message);
                return;
            }
        }
        public InsertResult Insert(InsertClientDto dto)
        {
            var insertResult = new InsertResult();

            //1) try create admin-user without client
            insertResult.identityResult = this.AddUser(null, dto);
            if (insertResult.identityResult.Succeeded)
            {
                //2) create client
                var client = Client.Create(ApplicationUser);
                client.Update(ApplicationUser, dto);
                uow.Client.Add(client);

                uow.SaveChanges();
                insertResult.clientId = client.id;

                //3) reference newly created admin-user to created client
                var succeededUser = UserManager.Users.FirstOrDefault(u => u.UserName == dto.userName);
                succeededUser.client_id = client.id;
                UserManager.Update(succeededUser);

                //4) create Standard UserGroup
                var userGroup = UserGroup.Create(ApplicationUser, client.id);
                userGroup.name      = client.name + "-Standard";
                userGroup.userRoles = ControllerBase.NonAdminRoleNames;
                uow.UserGroup.Add(userGroup);
                uow.SaveChanges();
            }

            return(insertResult);
        }
예제 #8
0
        /// <summary>
        /// Implementation to execute when insert action.
        /// </summary>
        /// <param name="input">stream input</param>
        /// <param name="context">Input context</param>
        /// <returns>
        /// <para>
        /// A <see cref="InsertResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b>
        /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property
        /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in.
        /// </para>
        /// <para>
        /// The type of the return value is <see cref="InsertResultData"/>, which contains the operation result
        /// </para>
        /// </returns>
        protected override InsertResult InsertImpl(Stream input, IInput context)
        {
            if (string.IsNullOrEmpty(SheetName))
            {
                return(InsertResult.CreateErroResult(
                           "Sheet name can not be null or empty",
                           new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            if (Location == null)
            {
                return(InsertResult.CreateSuccessResult(new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            if (Style == null)
            {
                Style = XlsxCellStyle.Default;
            }

            return(InsertImpl(context, input, SheetName, Data, Location, Style));
        }
예제 #9
0
        /// <summary>
        /// Implementation to execute when insert action.
        /// </summary>
        /// <param name="input">stream input</param>
        /// <param name="context">Input context</param>
        /// <returns>
        /// <para>
        /// A <see cref="InsertResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b>
        /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property
        /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in.
        /// </para>
        /// <para>
        /// The type of the return value is <see cref="InsertResultData"/>, which contains the operation result
        /// </para>
        /// </returns>
        protected override InsertResult InsertImpl(Stream input, IInput context)
        {
            if (string.IsNullOrEmpty(SheetName))
            {
                return(InsertResult.CreateErroResult(
                           "Source sheet name can not be null or empty",
                           new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            if (Destination == null)
            {
                return(InsertResult.CreateSuccessResult(new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            if (string.IsNullOrEmpty(Destination.WorkSheet))
            {
                return(InsertResult.CreateErroResult(
                           "Destination sheet name can not be null or empty",
                           new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            if (SourceRange == null)
            {
                return(InsertResult.CreateSuccessResult(new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            if (HeaderStyle == null)
            {
                HeaderStyle = XlsxCellStyle.Default;
            }

            if (ValueStyle == null)
            {
                ValueStyle = XlsxCellStyle.Default;
            }

            return(InsertImpl(context, input, SheetName, SourceRange, Destination, HeaderStyle, ValueStyle));
        }
예제 #10
0
        private void skinLabelAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (GlobalUtil.EngineUnconnectioned(this))
                {
                    return;
                }
                CostumeAddBrandForm addForm = new CostumeAddBrandForm();
                if (addForm.ShowDialog(this) == DialogResult.OK)
                {
                    List <Brand> list = (List <Brand>) this.skinComboBox.DataSource;
                    if (list == null)
                    {
                        list = new List <Brand>();
                    }
                    Brand value = addForm.Result;
                    //从所有品牌中查找
                    Brand listItem = CommonGlobalCache.BrandList.Find(t => t.Name == value.Name);
                    if (listItem == null)
                    {
                        //   Brand item = new Brand() { Name = value, FirstCharSpell = DisplayUtil.GetPYString(value) };
                        InsertResult result = GlobalCache.BrandList_OnInsert(value);
                        switch (result)
                        {
                        case InsertResult.Success:
                            this.skinComboBox.DataSource = null;
                            list.Add(value);
                            this.skinComboBox.DisplayMember = "Name";
                            this.skinComboBox.ValueMember   = "AutoID";
                            this.skinComboBox.DataSource    = list;
                            this.skinComboBox.SelectedIndex = list.IndexOf(value);
                            break;

                        case InsertResult.Error:
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        GlobalMessageBox.Show("品牌已存在");
                        //this.skinComboBox.SelectedItem = listItem;
                    }
                }
            }
            catch (Exception ex)
            {
                // GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }
예제 #11
0
        protected virtual void HandleInsertResult(TasksResponse tasksResponse, EntityDto entity)
        {
            InsertResult result = (InsertResult)tasksResponse.Results[0];

            this.CheckErrors(result.Errors);
            entity.Uid             = result.InsertedEntityUid;
            entity.LastUpdatedUid  = result.LastUpdatedUid;
            entity.UtcLastModified = result.UtcLastModified;
        }
예제 #12
0
        private static InsertResult InsertImpl(IInput context, Stream input, string sheetName, XlsxRange source, QualifiedPointDefinition destination)
        {
            var outputStream = new MemoryStream();

            try
            {
                using (var excel = new ExcelPackage(input))
                {
                    var sourceWorksheet = excel.Workbook.Worksheets.FirstOrDefault(worksheet => worksheet.Name.Equals(sheetName, StringComparison.OrdinalIgnoreCase));
                    if (sourceWorksheet == null)
                    {
                        return(InsertResult.CreateErroResult(
                                   $"source sheet '{sheetName}' not found",
                                   new InsertResultData
                        {
                            Context = context,
                            InputStream = input,
                            OutputStream = input
                        }));
                    }

                    var destinationWorksheet = excel.Workbook.Worksheets.FirstOrDefault(worksheet => worksheet.Name.Equals(destination.WorkSheet, StringComparison.OrdinalIgnoreCase));
                    if (destinationWorksheet == null)
                    {
                        return(InsertResult.CreateErroResult(
                                   $"Destination sheet '{sheetName}' not found",
                                   new InsertResultData
                        {
                            Context = context,
                            InputStream = input,
                            OutputStream = input
                        }));
                    }

                    sourceWorksheet.Cells[source.Start.Row, source.Start.Column, source.End.Row, source.End.Column].Copy(destinationWorksheet.Cells[destination.Point.Row, destination.Point.Column]);
                    excel.SaveAs(outputStream);

                    return(InsertResult.CreateSuccessResult(new InsertResultData
                    {
                        Context = context,
                        InputStream = input,
                        OutputStream = outputStream
                    }));
                }
            }
            catch (Exception ex)
            {
                return(InsertResult.FromException(
                           ex,
                           new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }
        }
예제 #13
0
        private static InsertResult InsertImpl(IInput context, Stream input, string sheetName, XlsxBaseRange location, XlsxShape xlsxShape)
        {
            var outputStream = new MemoryStream();

            try
            {
                using (var excel = new ExcelPackage(input))
                {
                    var ws = excel.Workbook.Worksheets.FirstOrDefault(worksheet => worksheet.Name.Equals(sheetName, StringComparison.OrdinalIgnoreCase));
                    if (ws == null)
                    {
                        return(InsertResult.CreateErroResult(
                                   $"Sheet '{sheetName}' not found",
                                   new InsertResultData
                        {
                            Context = context,
                            InputStream = input,
                            OutputStream = input
                        }));
                    }

                    var shapeName = xlsxShape.Name.HasValue() ? xlsxShape.Name : $"shape{ws.Drawings.Count}";
                    var shape     = ws.Drawings.AddShape(shapeName, eShapeStyle.Rect);

                    var writer = new OfficeOpenShapeWriter(shape, ws);
                    writer.SetBorder(xlsxShape.Border);
                    writer.SetContent(xlsxShape.Content);
                    writer.SetFont(xlsxShape.Content.Font);
                    writer.SetPosition(location);
                    writer.SetSize(xlsxShape.Size);
                    writer.SetShapeEffects(xlsxShape.ShapeEffects, shapeName);
                    writer.SetShapeStyle(xlsxShape.ShapeType);
                    writer.SetText(xlsxShape.Content.Text);

                    excel.SaveAs(outputStream);

                    return(InsertResult.CreateSuccessResult(new InsertResultData
                    {
                        Context = context,
                        InputStream = input,
                        OutputStream = outputStream
                    }));
                }
            }
            catch (Exception ex)
            {
                return(InsertResult.FromException(
                           ex,
                           new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }
        }
예제 #14
0
        private void BaseButton3_Click(object sender, EventArgs e)
        {
            try
            {
                if (pfCustomer == null)
                {
                    GlobalMessageBox.Show("客户不存在,请重新选择!");
                    skinComboBox_PfCustomer.Focus();
                    return;
                }
                if (textBoxAmount.Value == 0)
                {
                    GlobalMessageBox.Show("请输入回款金额!");
                    textBoxAmount.Focus();
                    return;
                }
                if (GlobalUtil.EngineUnconnectioned(this))
                {
                    return;
                }

                PfAccountRecord record = new PfAccountRecord()
                {
                    PfCustomerID = pfCustomer.ID,
                    CreateTime   = dateTimePicker_End.Value,
                    AccountMoney = -textBoxAmount.Value
                };
                InsertResult result = GlobalCache.ServerProxy.InsertPfAccountRecord4Fx(record);

                switch (result)
                {
                case InsertResult.Success:
                    GlobalMessageBox.Show("录入成功!");
                    //清空dataGirdView1的绑定源
                    textBoxAmount.Text           = string.Empty;
                    skinComboBox_PfCustomer.Text = null;
                    break;

                case InsertResult.Error:
                    GlobalMessageBox.Show("内部错误!");
                    break;

                default:
                    break;
                }
            }
            catch (Exception ee)
            {
                GlobalUtil.ShowError(ee);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }
예제 #15
0
        public void InsertResult_Success_ValidCall_ReturnTrue()
        {
            // Arrange
            var resp = "{ success: true}";

            // Act
            var actualRes = InsertResult.Success(resp);

            // Assert
            Assert.IsTrue(actualRes);
        }
예제 #16
0
        public async Task <ReinsertResult> ReInsert(Anuncio anuncio, string Key2Captcha, string email)
        {
            ReinsertResult    result;
            CaptchaAnswer     captchaResponse;
            FormInsertAnuncio formInsertAnuncio;
            FormDeleteAnuncio formDeleteAnuncio;

            try
            {
                // Get Anuncio

                string htmlAnuncio = await Requests.GetAsync(anuncio.Url);

                GetException(htmlAnuncio, anuncio.Url, false);

                // Parse All Data
                FormUpdateAnuncio formAnuncio = ParseFormAnuncio(htmlAnuncio);
                formAnuncio.variables.email = email;
                anuncio.FormUpdateAnuncio   = JsonConvert.SerializeObject(formAnuncio);

                //Solve Captcha
                captchaResponse = await ResolveCaptcha(Key2Captcha, Requests.RevolicoInserrUrl, htmlAnuncio);

                formAnuncio.variables.captchaResponse = captchaResponse.Answerv2;
                //formAnuncio.variables.botScore = captchaResponse.Answerv3;

                // Parse Insert and Delete Forms
                formInsertAnuncio = new FormInsertAnuncio(formAnuncio);
                formDeleteAnuncio = new FormDeleteAnuncio(formAnuncio);

                // Insert new Announce
                string answer = await InsertAnuncio(formInsertAnuncio);

                // Verify Insertion
                GetException(answer, anuncio.Url, true, captchaResponse);

                // Update new Anuncio URL
                InsertResult insertResult = ParseInsertResult(answer);
                anuncio.Url = $"{Requests.RevolicoModifyUrl}?key={insertResult.FullId}";
                _log.LogWarning($"ReplaceInsert {anuncio.Id} {insertResult.FullId}");

                // Delete from Revolico
                await DeleteFromRevolico(formDeleteAnuncio);

                result = new ReinsertResult(anuncio);
            }
            catch (Exception ex)
            {
                result = new ReinsertResult(anuncio, ex);
            }

            return(result);
        }
예제 #17
0
    public InsertResult InsertItem(Item item, ItemSlot slot, InventoryCellsGroup group, bool notify_if_cant, bool drop_if_cant)
    {
        if (this.m_Items.Contains(item))
        {
            return(InsertResult.CantInsert);
        }
        bool isStatic = item.gameObject.isStatic;

        item.gameObject.isStatic = false;
        item.transform.parent    = null;
        InsertResult insertResult = InsertResult.None;

        if (Storage3D.Get().GetGrid(this.m_Type).InsertItem(item, slot, group, true, true, this))
        {
            insertResult = InsertResult.Ok;
        }
        else
        {
            insertResult = InsertResult.NoSpace;
        }
        if (insertResult == InsertResult.Ok)
        {
            this.m_Items.Add(item);
            if (!item.m_CurrentSlot)
            {
                item.transform.parent = Storage3D.Get().transform;
            }
            item.OnAddToStorage(this);
            item.gameObject.SetActive(Inventory3DManager.Get().gameObject.activeSelf&& item.m_Info.m_BackpackPocket == Inventory3DManager.Get().m_ActivePocket);
            using (List <Item> .Enumerator enumerator = this.m_Items.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Item item2 = enumerator.Current;
                    item2.UpdatePhx();
                    item2.UpdateScale(false);
                    item.UpdateLayer();
                }
                return(insertResult);
            }
        }
        item.gameObject.isStatic = isStatic;
        if (notify_if_cant)
        {
            ((HUDMessages)HUDManager.Get().GetHUD(typeof(HUDMessages))).AddMessage(GreenHellGame.Instance.GetLocalization().Get("HUD_NoSpaceInStorage", true), new Color?(Color.red), HUDMessageIcon.None, "", null);
            HUDManager.Get().PlaySound("Sounds/HUD/GH_Inventory_Full");
        }
        if (drop_if_cant)
        {
            Inventory3DManager.Get().DropItem(item);
        }
        return(insertResult);
    }
예제 #18
0
        public void InsertResult_SuccessId_ValidCall_ReturnTrue()
        {
            // Arrange
            var successId = "1";
            var resp      = $"{{ id: {successId}}}";

            // Act
            var actualRes = InsertResult.SuccessId(resp);

            // Assert
            Assert.AreEqual(successId, actualRes);
        }
예제 #19
0
        private static InsertResult InsertImpl <T>(IInput context, Stream input, string sheetName, IEnumerable <T> data, XlsxBaseRange location, YesNo showHeaders, XlsxCellStyle style)
        {
            var outputStream = new MemoryStream();

            try
            {
                using (var excel = new ExcelPackage(input))
                {
                    var ws = excel.Workbook.Worksheets.FirstOrDefault(worksheet => worksheet.Name.Equals(sheetName, StringComparison.OrdinalIgnoreCase));
                    if (ws == null)
                    {
                        return(InsertResult.CreateErroResult(
                                   $"Sheet '{sheetName}' not found",
                                   new InsertResultData
                        {
                            Context = context,
                            InputStream = input,
                            OutputStream = input
                        }));
                    }

                    var safeData = data.ToList();
                    ExcelAddressBase locationAddress = location.ToEppExcelAddress();
                    ws.Cells[locationAddress.ToString()].LoadFromCollection(safeData, showHeaders == YesNo.Yes);

                    XlsxCellStyle styleToUse = excel.CreateStyle(style);
                    var           range      = ws.Cells[locationAddress.Start.Row, locationAddress.Start.Column, locationAddress.End.Row + safeData.Count - 1, locationAddress.End.Column];
                    range.StyleName = styleToUse.Name;

                    excel.SaveAs(outputStream);

                    return(InsertResult.CreateSuccessResult(new InsertResultData
                    {
                        Context = context,
                        InputStream = input,
                        OutputStream = outputStream
                    }));
                }
            }
            catch (Exception ex)
            {
                return(InsertResult.FromException(
                           ex,
                           new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }
        }
예제 #20
0
        public InsertResult InputMeterReadings(IEnumerable <MeterReading> readings, IDataRepository dataRepo)
        {
            //Create the single insertResults
            InsertResult insertResult = new InsertResult();

            //Validate the readings before submitting them to the DB (where further validation is implemented).
            ValidateMeterReadings(ref readings, dataRepo, ref insertResult);

            //Submit these validated values to the DB.
            SubmitValidatedMeterReadings(ref readings, dataRepo, ref insertResult);

            //Return for display to the user.
            return(insertResult);
        }
예제 #21
0
        protected override async Task InsertAsync(InsertArgs args, InsertResult result)
        {
            var rowDest = new FrameworkConfigGrid();

            Data.RowCopy(args.Row, rowDest);
            rowDest.IsExist = true;
            await Data.InsertAsync(rowDest);

            var rowReload = await Reload(args.Row);

            Data.RowCopy(rowReload, args.Row);

            result.IsHandled = true;
        }
예제 #22
0
        private void baseButton2_Click(object sender, EventArgs e)
        {
            List <Brand> list = null;

            if (dataGridView1.DataSource != null)
            {
                list = DataGridViewUtil.BindingListToList <Brand>(dataGridView1.DataSource);
            }
            //List<Brand> list = DataGridViewUtil.BindingListToList<Brand>(dataGridView1.DataSource);
            CostumeAddBrandForm AddBrand = new CostumeAddBrandForm();

            try
            {
                if (AddBrand.ShowDialog(this) == DialogResult.OK)
                {
                    if (list == null)
                    {
                        list = new List <Brand>();
                    }
                    Brand item = AddBrand.Result;
                    list.Add(item);
                    InsertResult result = GlobalCache.BrandList_OnInsert(item);
                    if (GlobalUtil.EngineUnconnectioned(this))
                    {
                        return;
                    }
                    switch (result)
                    {
                    case InsertResult.Success:
                        baseButton1_Click(sender, e);
                        break;

                    case InsertResult.Error:
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }
        public async Task Insert()
        {
            CompanyMessage message = new CompanyMessage()
            {
                Text    = $"Test message # {DateTime.UtcNow.ToShortTimeString()}",
                Company = 1
            };

            InsertResult <CompanyMessage> result = await CompanyMessageRepository.InsertAsync(message);

            Console.WriteLine($"Success:{result.Success}\nCollectionId:{result.CollectionId}\nInserted:\n{JToken.Parse(JsonConvert.SerializeObject(result.Result)).ToString(Formatting.Indented)}");

            Assert.IsNotNull(result.Result);
            Assert.IsInstanceOfType(result.Result, typeof(CompanyMessage));
        }
예제 #24
0
        private static InsertResult InsertImpl(IInput context, Stream input, string sheetName, XlsxBaseRange location, string file)
        {
            var outputStream = new MemoryStream();

            try
            {
                using (var excel = new ExcelPackage(input))
                {
                    var ws = excel.Workbook.Worksheets.FirstOrDefault(worksheet => worksheet.Name.Equals(sheetName, StringComparison.OrdinalIgnoreCase));
                    if (ws == null)
                    {
                        return(InsertResult.CreateErroResult(
                                   $"Sheet '{sheetName}' not found",
                                   new InsertResultData
                        {
                            Context = context,
                            InputStream = input,
                            OutputStream = input
                        }));
                    }

                    ExcelAddressBase locationAddress = location.ToEppExcelAddress();
                    //ws.Cells[locationAddress.ToString()].lo(data, true);

                    var a = LoadXmlFromFile(file, "*");

                    excel.SaveAs(outputStream);

                    return(InsertResult.CreateSuccessResult(new InsertResultData
                    {
                        Context = context,
                        InputStream = input,
                        OutputStream = outputStream
                    }));
                }
            }
            catch (Exception ex)
            {
                return(InsertResult.FromException(
                           ex,
                           new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }
        }
예제 #25
0
        /// <summary>
        /// Implementation to execute when insert action.
        /// </summary>
        /// <param name="input">stream input</param>
        /// <param name="context">Input context</param>
        /// <returns>
        /// <para>
        /// A <see cref="InsertResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b>
        /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property
        /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in.
        /// </para>
        /// <para>
        /// The type of the return value is <see cref="InsertResultData"/>, which contains the operation result
        /// </para>
        /// </returns>
        protected override InsertResult InsertImpl(Stream input, IInput context)
        {
            if (string.IsNullOrEmpty(SheetName))
            {
                return(InsertResult.CreateErroResult(
                           "Sheet name can not be null or empty",
                           new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            if (Location == null)
            {
                return(InsertResult.CreateSuccessResult(new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            if (Picture == null)
            {
                return(InsertResult.CreateSuccessResult(new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            if (Picture.Show == YesNo.No)
            {
                return(InsertResult.CreateSuccessResult(new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }

            return(InsertImpl(context, input, SheetName, Location, Picture));
        }
예제 #26
0
        private IComparable InsertObject(object obj)
        {
            IComparable[] row = GetRow(obj);

            string tableName = obj.GetType().Name;

            InsertResult result = _interpreter.RunInsert(row, tableName);

            PropertyInfo identityProperty = GetIdentityColumn(obj);

            if (identityProperty != null)
            {
                identityProperty.SetValue(obj, result.IdentityValue);
            }

            return(result.IdentityValue);
        }
예제 #27
0
    private bool AddItemToBackpack()
    {
        Item         item         = ItemsManager.Get().CreateItem(this.m_StoredItemId, true, Vector3.zero, Quaternion.identity);
        InsertResult insertResult = InventoryBackpack.Get().InsertItem(item, null, null, true, true, true, true, true);
        bool         flag         = InsertResult.Ok == insertResult;

        if (!flag)
        {
            UnityEngine.Object.Destroy(item.gameObject);
            this.m_NumItems++;
            this.UpdateVis();
            return(flag);
        }
        this.PlayInsertSound();
        base.AddItemsCountMessage(item);
        return(flag);
    }
예제 #28
0
        private static InsertResult InsertImpl(IInput context, Stream input, int page, PdfImage image, PointF imageOffset, PdfImageStyle style)
        {
            var outputStream = new MemoryStream();

            try
            {
                var reader  = new TextSharp.PdfReader(input);
                var stamper = new TextSharp.PdfStamper(reader, outputStream);

                var pages = reader.NumberOfPages;
                for (var pdfPage = 1; pdfPage <= pages; pdfPage++)
                {
                    if (pdfPage != page)
                    {
                        continue;
                    }

                    var cb = stamper.GetOverContent(pdfPage);
                    image.Image.SetAbsolutePosition(imageOffset.X, imageOffset.Y);
                    cb.AddImage(image.Image);
                    break;
                }

                stamper.Close();
                reader.Close();

                return(InsertResult.CreateSuccessResult(new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = new MemoryStream(outputStream.GetBuffer())
                }));
            }
            catch (Exception ex)
            {
                return(InsertResult.FromException(
                           ex,
                           new InsertResultData
                {
                    Context = context,
                    InputStream = input,
                    OutputStream = input
                }));
            }
        }
예제 #29
0
        protected override async Task InsertAsync(InsertArgs args, InsertResult result)
        {
            var rowDest = new FrameworkConfigGrid();

            Data.RowCopy(args.Row, rowDest);
            int tableId = (await Data.Query <FrameworkTable>().Where(item => item.TableNameCSharp == TableNameCSharp).QueryExecuteAsync()).Single().Id;

            rowDest.TableId  = tableId;
            rowDest.IsDelete = false;
            await Data.InsertAsync(rowDest);

            Data.RowCopy(rowDest, result.Row);
            var rowReload = await Reload(result.Row);

            Data.RowCopy(rowReload, result.Row);

            result.IsHandled = true;
        }
예제 #30
0
        protected override async Task InsertAsync(InsertArgs args, InsertResult result)
        {
            var row = new StorageFile();

            Data.RowCopy(args.Row, row);
            if (args.FileUpload != null)
            {
                row.Data            = args.FileUpload.Data;
                row.FileName        = args.FileUpload.FileName;
                result.Row.FileName = row.FileName;
                result.Row.IsData   = true;
            }
            row.IsIntegrate = true;
            await Data.InsertAsync(row);

            result.Row.Id    = row.Id;
            result.IsHandled = true;
        }