Exemple #1
1
        public void ProcessRequest(HttpContext context) {
            context.Response.ContentType = "text/xml";// the data is passed in XML format

            var action = new DataAction(context.Request.Form);
            var data = new SchedulerDataContext();

            try {
                var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), context.Request.Form);

                switch (action.Type) {
                    case DataActionTypes.Insert: // Insert logic
                        data.Events.InsertOnSubmit(changedEvent);
                        break;
                    case DataActionTypes.Delete: // Delete logic
                        changedEvent = data.Events.SingleOrDefault(ev => ev.EventID == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                        break;
                    default:// "update" // Update logic
                        var updated = data.Events.SingleOrDefault(ev => ev.EventID == action.SourceId);
                        DHXEventsHelper.Update(updated, changedEvent, new List<string>() { "EventID" });
                        break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.EventID;
            } catch (Exception) {
                action.Type = DataActionTypes.Error;
            }

            context.Response.Write(new AjaxSaveResponse(action));
        }
Exemple #2
0
        public static string GetElementForRowView(this Field field, DataAction dataAction, object data, string guid)
        {
            switch (dataAction)
            {
            case DataAction.Create:
                string pk = string.Empty;
                if (data != null && data is string)
                {
                    pk = (string)data;
                }
                return(FieldExtentions.GetElementForCreate(field, pk, string.Empty, guid));

            case DataAction.Edit:
                if (data != null && data is DataRow)
                {
                    DataRow dataRow = (DataRow)data;

                    return(FieldExtentions.GetElementForEdit(field, dataRow, guid));
                }
                else
                {
                    return(FieldExtentions.GetElementForEdit(field, string.Empty, string.Empty, guid));
                }

            case DataAction.InlineAdding:
                return(FieldExtentions.GetElementForInlineAdding(field, guid));

            default:
                throw new NotSupportedException();
            }
        }
        public void NegativeTestCopy()
        {
            var    dataAction = new DataAction(_dataPlace);
            string copyPath   = "Q:\\UNBELIEVABLE\\PATH";

            Assert.Catch <IOException>(() => dataAction.CopyTo(copyPath));
        }
        public void NegativeTestArchive()
        {
            var    dataAction  = new DataAction(_dataPlace);
            string archivePath = "Q:\\UNBELIEVABLE\\PATH";

            Assert.Catch <IOException>(() => dataAction.ArchiveTo(archivePath));
        }
        public ContentResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = (CalendarEvent)DHXEventsHelper.Bind(typeof(CalendarEvent), actionValues);

                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        action.TargetId = Insert(changedEvent);
                        break;
                    case DataActionTypes.Delete:

                        Delete(changedEvent);

                        break;
                    default:
                        Update(changedEvent);
                        break;
                }
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return (ContentResult)new AjaxSaveResponse(action);
        }
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = DHXEventsHelper.Bind <Calendar>(actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    db.Appointments.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    db.Entry(changedEvent).State = EntityState.Deleted;
                    break;

                default:    // "update"
                    db.Entry(changedEvent).State = EntityState.Modified;
                    break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
Exemple #7
0
 public void CopyFromDataAction(DataAction da)
 {
     actionValue             = da.actionValue;
     actionDurationInSeconds = da.actionEffectDurationInSeconds;
     actionName     = da.actionName;
     dataSourceName = da.dataSource != null ? da.dataSource.dataName : null;
 }
Exemple #8
0
        protected override string GetJsonViewSerialized(View view, DataAction dataAction, Durados.Web.Mvc.UI.Json.View jsonView)
        {
            if (dataAction == DataAction.Create)
            {
                string ownerFieldName;
                //if (view.Name == CRMViews.v_ProposalLast2Months.ToString())
                if (view.Name == ProposalLastViewName)
                {
                    ownerFieldName = User_Proposal_Last_Parent;
                }
                //ownerFieldName = v_ProposalLast2Months.FK_Proposal_User_Parent.ToString();
                else
                {
                    ownerFieldName = User_Proposal_Parent;
                }
                //ownerFieldName = Proposal.User_Proposal_Parent.ToString();

                if (jsonView.Fields.ContainsKey(ownerFieldName))
                {
                    //string userPK = GetUserRow()[User.ID.ToString()].ToString();
                    string userPK = GetUserRow()[User_PK].ToString();
                    jsonView.Fields[ownerFieldName].Default = userPK;
                }
            }
            //v_ProposalLast2Months
            return(base.GetJsonViewSerialized(view, dataAction, jsonView));
        }
Exemple #9
0
        /// <summary>
        /// Grabs HTML copied in the clipboard and pastes it into the document (pulls in a copy of embedded content too)
        /// </summary>
        protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
        {
            using (new WaitCursor())
            {
                try
                {
                    // get the list of files from the data meister
                    FileItem[] files = DataMeister.FileData.Files;

                    string[] filePaths = new string[files.Length];
                    // create an array of file entities to insert
                    for (int i = 0; i < files.Length; i++)
                    {
                        filePaths[i] = files[i].ContentsPath;
                    }

                    string html = EditorContext.HtmlGenerationService.GenerateHtmlFromFiles(filePaths);
                    EditorContext.InsertHtml(begin, end, html, null);

                    //place the caret at the end of the inserted content
                    //EditorContext.MoveCaretToMarkupPointer(end, true);
                    return(true);
                }
                catch (Exception e)
                {
                    //bugfix 1696, put exceptions into the trace log.
                    Trace.Fail("Exception while inserting HTML: " + e.Message, e.StackTrace);
                    return(false);
                }
            }
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                AppointmentViewModelFull appointmentViewModel = (AppointmentViewModelFull)DHXEventsHelper.Bind(typeof(AppointmentViewModelFull), actionValues);

                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    int patientID = int.Parse(sessionStateManger.getSecyrtaryActivePatinet(User.Identity.GetUserId()));
                    appointmentViewModel.ClinicID  = sessionStateManger.getClinecIDForCurrentSecurtary(User.Identity.GetUserId());
                    appointmentViewModel.PatientID = patientID;
                    appointmentViewModel.Status    = appointmentViewModel.Status;
                    appointmentViewModel.text      = "DR:" + doctorRepository.getDoctorNameByID(appointmentViewModel.DoctorID) + " Patient:" + patientRepository.getPatientNameByID(patientID);
                    action.TargetId = appointmentRepository.AddNewAppointment(appointmentViewModel);
                    break;

                case DataActionTypes.Delete:
                    appointmentRepository.deleteAppointment(appointmentViewModel.id);
                    break;

                default:
                    appointmentRepository.alterAppointment(appointmentViewModel);
                    break;
                }
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return(Content(new AjaxSaveResponse(action), "text/xml"));
        }
Exemple #11
0
        public static bool IsDisable(this Field field, DataAction dataAction, string guid)
        {
            if (field.View.SystemView)
            {
                return(false);
            }

            switch (dataAction)
            {
            case DataAction.Create:
                return(IsDisableForCreate(field));

            case DataAction.Edit:
                return(IsDisableForEdit(field, guid));

            case DataAction.InlineAdding:
                return(IsDisableForCreate(field));

            case DataAction.InlineEditing:
                return(IsDisableForEdit(field, guid));

            default:
                throw new NotImplementedException();
            }
        }
Exemple #12
0
        public ActionResult SystemRolesMain(DataAction ActionType, string guid, string selectEmail, string selectUserName, int pages = 1)
        {
            AspNetUsersDetailViewModel data = new AspNetUsersDetailViewModel();

            if (ActionType == DataAction.Update)
            {
                data = _UserService.ReturnAspNetUsersDetail(ActionType, guid);
            }

            #region KeepSelectBlock

            TempData["Actions"] = ActionType;
            pages = pages == 0 ? 1 : pages;
            TempData["SystemRolesSelect"] = new SystemRolesViewModel()
            {
                Header = new SystemRolesListHeaderViewModel()
                {
                    Email    = selectEmail,
                    UserName = selectUserName
                },
                page = pages
            };

            #endregion KeepSelectBlock

            return(View(data));
        }
Exemple #13
0
        protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
        {
            // get the table and its cells
            IHTMLTable             sourceTable = GetSourceTable(DataMeister);
            IHTMLElementCollection cells       = (sourceTable as IHTMLElement2).getElementsByTagName("td");

            // single-cell tables just get the innerHTML of the cell pasted at the selection
            if (cells.length == 1)
            {
                IHTMLElement cell = cells.item(0, 0) as IHTMLElement;
                EditorContext.InsertHtml(begin, end, cell.innerHTML, UrlHelper.GetBaseUrl(DataMeister.HTMLData.SourceURL));
            }
            else
            {
                // if we are inside a table
                TableSelection tableSelection = new TableSelection(EditorContext.MarkupServices.CreateMarkupRange(begin, end));
                if (tableSelection.Table != null)
                {
                    // paste the source cells into the table
                    PasteCellsIntoTable(sourceTable, tableSelection);
                }
                else
                {
                    // get table html (make sure width matches # of rows selected)
                    TableHelper.SynchronizeTableWidthForEditing(sourceTable);
                    string html = (sourceTable as IHTMLElement).outerHTML;

                    // insert the html (nests within an undo unit)
                    EditorContext.InsertHtml(begin, end, html, UrlHelper.GetBaseUrl(DataMeister.HTMLData.SourceURL));
                }
            }

            return(true);
        }
Exemple #14
0
        private void UpdateData()
        {
            _bindingSource.EndEdit();
            if (!_data.DataChanged)
            {
                this.DialogResult = DialogResult.Cancel;
            }
            else
            {
                DataAction dataAction = (_frmDesigner.formAction == FormAction.Edit) ? DataAction.Update : DataAction.Insert;
                _data.CheckRules(dataAction);
                //if (dxErrorProviderMain.HasErrors)
                //{
                //    XtraMessageBox.Show("Số liệu chưa hợp lệ, vui lòng kiểm tra lại trước khi lưu!");
                //    return;
                //}

                if (this._data.UpdateData(dataAction))
                {
                    _x = false;
                    this.DialogResult = DialogResult.OK;
                }
                else if (dxErrorProviderMain.HasErrors)
                {
                    XtraMessageBox.Show("Số liệu chưa hợp lệ, vui lòng kiểm tra lại trước khi lưu!");
                }
                else
                {
                    XtraMessageBox.Show("Số liệu chưa hợp lệ, vui lòng kiểm tra lại trước khi lưu! Xem quyền update Item");
                }
            }
        }
Exemple #15
0
 protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
 {
     //hack: drive the selection textRange to the caret (before calling InsertImages)
     EditorContext.MarkupServices.CreateMarkupRange(begin, end).ToTextRange().select();
     _blogEditor.InsertSmartContentFromFile(new string[] { DataMeister.FileData.Files[0].ContentsPath }, VideoContentSource.ID, HtmlInsertionOptions.Default, null);
     return(true);
 }
        public ContentResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = (CalendarEvent)DHXEventsHelper.Bind(typeof(CalendarEvent), actionValues);

                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        //do insert
                        // action.TargetId = changedEvent.id;//assign postoperational id
                        break;
                    case DataActionTypes.Delete:
                        //do delete
                        break;
                    default:// "update"
                        //do update
                        break;
                }
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return (ContentResult)new AjaxSaveResponse(action);
        }
Exemple #17
0
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = DHXEventsHelper.Bind <gEvent>(actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    existEvent.myEvent.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:     //will add later
                    break;

                default:    // "update" add later
                    break;
                }


                action.TargetId = changedEvent.Id;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var    action      = new DataAction(actionValues);
            var    stylists    = db.Stylists.ToList();
            string currentUser = User.Identity.GetUserId();
            var    stylistInfo = db.Stylists.Where(c => c.UserId.Equals(currentUser)).FirstOrDefault();

            try
            {
                var changedEvent = DHXEventsHelper.Bind <Event>(actionValues);
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    changedEvent.StylistId = stylistInfo.Id;
                    db.Events.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    db.Entry(changedEvent).State = EntityState.Deleted;
                    break;

                default:    // "update"
                    db.Entry(changedEvent).State = EntityState.Modified;
                    break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        private List <Button> GetActionButtons(long tenantId, long domainId, DataAction action)
        {
            Button readButton = new Button
            {
                Text          = DomainResource.ReadDomainTabLabel,
                Icon          = Icon.Read,
                UrlParameters = new UrlParameters {
                    ControllerName = "domains", ActionName = "read", RouteValues = new { domainid = domainId }
                },
                State = action == DataAction.Read ? ButtonState.Active : ButtonState.Enabled
            };
            Button updateButton = new Button
            {
                Text          = DomainResource.UpdateDomainTabLabel,
                Icon          = Icon.Update,
                UrlParameters = new UrlParameters {
                    ControllerName = "domains", ActionName = "update", RouteValues = new { domainid = domainId }
                },
                State = action == DataAction.Update ? ButtonState.Active : ButtonState.Enabled
            };
            Button deleteButton = new Button
            {
                Text          = DomainResource.DeleteDomainTabLabel,
                Icon          = Icon.Delete,
                UrlParameters = new UrlParameters {
                    ControllerName = "domains", ActionName = "delete", RouteValues = new { domainid = domainId }
                },
                State = action == DataAction.Delete ? ButtonState.Active : ButtonState.Enabled
            };

            return(new List <Button> {
                readButton, updateButton, deleteButton
            });
        }
Exemple #20
0
        public ActionResult ActivitiesMain(DataAction ActionType, string guid, string selectCreateTime,
                                           string selectTitleName, string selectHtmlContext, string selectStartDate, string selectEndDate, int pages = 1)
        {
            TempData["DataAction"] = ActionType;
            ActitiesDetailViewModel data = new ActitiesDetailViewModel();

            data = _ActivityService.ReturnActitiesDetailViewModel(ActionType, guid);

            #region KeepSelectBlock

            pages = pages == 0 ? 1 : pages;
            TempData["ActitiesSelect"] = new ActitiesViewModel()
            {
                Header = new ActitiesListHeaderViewModel()
                {
                    CreateTime  = selectCreateTime,
                    EndDate     = selectEndDate,
                    HtmlContext = selectHtmlContext,
                    StartDate   = selectStartDate,
                    TitleName   = selectTitleName
                },
                page = pages
            };

            #endregion KeepSelectBlock

            return(View(data));
        }
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = DHXEventsHelper.Bind <Calendario>(actionValues, new System.Globalization.CultureInfo("pt-BR"));
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    db.Calendario.Add(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    db.Entry(changedEvent).State = EntityState.Deleted;
                    break;

                default:    // "update"
                    db.Entry(changedEvent).State = EntityState.Modified;
                    break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
        {
            // get the table and its cells
            IHTMLTable sourceTable = GetSourceTable(DataMeister);
            IHTMLElementCollection cells = (sourceTable as IHTMLElement2).getElementsByTagName("td");

            // single-cell tables just get the innerHTML of the cell pasted at the selection
            if (cells.length == 1)
            {
                IHTMLElement cell = cells.item(0, 0) as IHTMLElement;
                EditorContext.InsertHtml(begin, end, cell.innerHTML, UrlHelper.GetBaseUrl(DataMeister.HTMLData.SourceURL));
            }
            else
            {
                // if we are inside a table
                TableSelection tableSelection = new TableSelection(EditorContext.MarkupServices.CreateMarkupRange(begin, end));
                if (tableSelection.Table != null)
                {
                    // paste the source cells into the table
                    PasteCellsIntoTable(sourceTable, tableSelection);
                }
                else
                {
                    // get table html (make sure width matches # of rows selected)
                    TableHelper.SynchronizeTableWidthForEditing(sourceTable);
                    string html = (sourceTable as IHTMLElement).outerHTML;

                    // insert the html (nests within an undo unit)
                    EditorContext.InsertHtml(begin, end, html, UrlHelper.GetBaseUrl(DataMeister.HTMLData.SourceURL));
                }
            }

            return true;
        }
        public ContentResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            var changedEvent = DHXEventsHelper.Bind<Event>(actionValues);
            DHXSchedulerDataContext data = new DHXSchedulerDataContext();
            try
            {
                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        data.Events.InsertOnSubmit(changedEvent);
                        break;
                    case DataActionTypes.Delete:
                        changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                        break;
                    default:// "update"
                        var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                        break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return (new AjaxSaveResponse(action));
        }
Exemple #24
0
 public DataMessage(DataAction action, string key, byte[] data, IAddress source)
 {
     Action = action;
     Key    = key;
     Data   = data;
     Source = source;
 }
 public void Push(TimeEntryData data, DataAction action)
 {
     if (observer != null)
     {
         observer.OnNext(new TimeEntryMessage(data, action));
     }
 }
Exemple #26
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            //var changedEvent = DHXEventsHelper.Bind<Event>(actionValues);
            //var entities = new SchedulerContext();
            //try
            //{
            //    switch (action.Type)
            //    {
            //        case DataActionTypes.Insert:
            //            entities.Events.Add(changedEvent);
            //            break;
            //        case DataActionTypes.Delete:
            //            changedEvent = entities.Events.FirstOrDefault(ev => ev.id == action.SourceId);
            //            entities.Events.Remove(changedEvent);
            //            break;
            //        default:// "update"
            //            var target = entities.Events.Single(e => e.id == changedEvent.id);
            //            DHXEventsHelper.Update(target, changedEvent, new List<string> { "id" });
            //            break;
            //    }
            //    entities.SaveChanges();
            //    action.TargetId = changedEvent.id;
            //}
            //catch (Exception a)
            //{
            //    action.Type = DataActionTypes.Error;
            //}

            return(new AjaxSaveResponse(action));
        }
        public ContentResult NativeSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            var data = new DHXSchedulerDataContext();

            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    data.ValidEvents.InsertOnSubmit(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    changedEvent = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    data.ValidEvents.DeleteOnSubmit(changedEvent);
                    break;

                default:    // "update"
                    var eventToUpdate = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                    {
                        "id"
                    });
                    break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        public async Task Post(DataAction <Quote> action)
        {
            if (!Authentication.IsAuthenticated(this.Request))
            {
                return;
            }

            Table <Quote> quotesDb = new Table <Quote>("KupoNuts_Quotes", Quote.Version);
            await quotesDb.Connect();

            switch (action.Action)
            {
            case Actions.Update:
            {
                await quotesDb.Save(action.Data);

                break;
            }

            case Actions.Delete:
            case Actions.DeleteConfirmed:
            {
                Log.Write("Delete Event: \"" + action.Data.Content + "\" (" + action.Data.Id + ")", "Manager");
                await quotesDb.Delete(action.Data);

                break;
            }
            }
        }
Exemple #29
0
        public string GetFieldValuesFromDialogIntoTable(View view, DataAction dataAction)
        {
            StringBuilder fieldValuesFromTableIntoDialog = new StringBuilder();

            foreach (Field field in view.GetVisibleFieldsForRow(dataAction))
            {
                if (field is ColumnField && ((ColumnField)field).GetHtmlControlType() == HtmlControlType.Check)
                {
                    fieldValuesFromTableIntoDialog.Append("$('#' + pk + ' [colname=" + field.Name + "]').attr('checked',$('#" + field.Name + "').attr('checked'));$('#' + pk + ' [colname=" + field.Name + "]').css('visibility','visible');");
                }
                else if (field is ColumnField && ((ColumnField)field).GetHtmlControlType() == HtmlControlType.TextArea)
                {
                    fieldValuesFromTableIntoDialog.Append("$('#' + pk + ' [colname=" + field.Name + "]')[0].firstChild.nodeValue = $('#" + field.Name + "').text();");
                    //fieldValuesFromTableIntoDialog += "$('#" + field.Name + "').text($('#' + pk + ' [colname=" + field.Name + "]')[0].firstChild.nodeValue);";
                }
                else if (field is ColumnField)
                {
                    fieldValuesFromTableIntoDialog.Append("$('#' + pk + ' [colname=" + field.Name + "]')[0].firstChild.nodeValue = $('#" + field.Name + "').val();");
                }
                else if (field is ParentField && ((ParentField)field).ParentHtmlControlType == ParentHtmlControlType.DropDown)
                {
                    fieldValuesFromTableIntoDialog.Append("$('#' + pk + ' [colname=" + field.Name + "]')[0].attributes['pk'].value = $('#" + field.Name + "').val();");
                }
                else if (field is ParentField)
                {
                    fieldValuesFromTableIntoDialog.Append("$('#' + pk + ' [colname=" + field.Name + "]')[0].firstChild.nodeValue = $('#" + field.Name + "').val();");
                }
            }

            return(fieldValuesFromTableIntoDialog.ToString());
        }
        public ActionResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
 
            try
            {
                var changedEvent = DHXEventsHelper.Bind<Appointment>(actionValues);
                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        db.Appointments.Add(changedEvent);
                        break;
                    case DataActionTypes.Delete:
                        db.Entry(changedEvent).State = EntityState.Deleted;
                        break;
                    default:// "update"  
                        db.Entry(changedEvent).State = EntityState.Modified;
                        break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception a)
            {
                action.Type = DataActionTypes.Error;
            }
 
            return (new AjaxSaveResponse(action));
        }
        /// <summary>
        /// Get the data action associated with the passed DragDropEffects
        /// </summary>
        /// <param name="effect">effects</param>
        /// <returns>data action</returns>
        private DataAction GetDataAction(DragDropEffects effect)
        {
            // default to copy
            DataAction dataAction = DataAction.Copy;

            // examine effects and set action as appropriate
            if (effect == DragDropEffects.Copy || effect == DragDropEffects.Link)
            {
                dataAction = DataAction.Copy;
            }
            else if (effect == DragDropEffects.Move)
            {
                dataAction = DataAction.Move;
            }
            else if (effect == (DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move))
            {
                dataAction = DataAction.Move;
            }
            else
            {
                Debug.Fail("Unexpected DragDropEffects!");
            }

            // return the action
            return(dataAction);
        }
Exemple #32
0
        public override bool UpdateData(DataAction dataAction)
        {
            if (!_dataChanged)
            {
                return(true);
            }

            bool isError = false;

            try
            {
                DbData.BeginMultiTrans();
                int index = DsData.Tables[0].Rows.IndexOf(_drCurrentMaster);

                if (!_customize.BeforeUpdate(index, DsData))
                {
                    DbData.RollbackMultiTrans();
                    return(false);
                }

                bool isNew = _drCurrentMaster.RowState == DataRowState.Added;
                if (Update(_drCurrentMaster))
                {
                    isError = isError || !TransferData(dataAction, index);
                    _customize.AfterUpdate();
                }
                else
                {
                    isError = true;
                }
                //
                if (!isError)
                {
                    DbData.EndMultiTrans();
                }
                else
                {
                    DbData.RollbackMultiTrans();
                }
                if (isNew && !isError)
                {
                    _autoIncreValues.UpdateNewStruct(_drCurrentMaster);
                }
                if (!isError)
                {
                    base.InsertHistory(dataAction, DsData);
                    DsData.AcceptChanges();
                    _dsDataTmp = DsData.Copy();
                }
                DataChanged = false;
            }
            finally
            {
                if (DbData.Connection.State != ConnectionState.Closed)
                {
                    DbData.Connection.Close();
                }
            }
            return(!isError);
        }
Exemple #33
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                var changedEvent = (CalendarEvent)DHXEventsHelper.Bind(typeof(CalendarEvent), actionValues);



                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    //do insert
                    // action.TargetId = changedEvent.id;//assign postoperational id
                    break;

                case DataActionTypes.Delete:
                    //do delete
                    break;

                default:    // "update"
                    //do update
                    break;
                }
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return((ContentResult) new AjaxSaveResponse(action));
        }
Exemple #34
0
        public ContentResult NativeSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    Repository.CreateValidEvent(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    changedEvent = Repository.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    Repository.RemoveValidEvent((int)action.SourceId);
                    break;

                default:    // "update"
                    var eventToUpdate = Repository.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    Repository.UpdateValidEvent(changedEvent);
                    DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                    {
                        "id"
                    });
                    break;
                }
                //data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        ///// <summary>
        ///// 若一条记录里有多个单上传控件字段,则每个上传控件的文件名和主键需保持一致
        ///// </summary>
        ///// <param name="path"></param>
        ///// <param name="fileStorageName"></param>
        ///// <returns></returns>
        //protected string GetSingleResourceInfo(string path, string fileStorageName)
        //{
        //    if (!path.IsEmpty())
        //    {
        //        var pathInfo = path.Split('&');
        //        string fileName = pathInfo[0].Substring(pathInfo[0].LastIndexOf('/') + 1);
        //        string fileID = fileName.Split('.')[0];
        //        string pathID = fileName.Substring(0, 8);
        //        string fileExt = Path.GetExtension(fileName);
        //        if (FileID.IsEmpty())
        //        {
        //            FileID = fileID;
        //        }
        //        else
        //        {
        //            //重命名
        //            string fullPath = new Uri(Path.Combine(FileManagementUtil.GetRootPath(fileStorageName, FilePathScheme.Physical), path)).LocalPath;
        //            string dir = Path.GetDirectoryName(fullPath);
        //            string newPath = new Uri(Path.Combine(dir, "\\" + FileID + fileExt)).LocalPath;
        //            File.Move(fullPath, newPath);
        //            File.Delete(fullPath);
        //            fileID = FileID;
        //        }
        //        var resourceInfo = new ResourceInfo();
        //        resourceInfo.InfoType = ResourceInfoType.Config;
        //        resourceInfo.FileId = fileID;
        //        resourceInfo.PathID = pathID.Value<int>();
        //        resourceInfo.ExtName = fileExt;
        //        resourceInfo.FileNameTitle = pathInfo[1];
        //        resourceInfo.FileSizeK = pathInfo[2].Value<int>();
        //        resourceInfo.StorageConfigName = fileStorageName;
        //        return AppContext.Current.FastJson.ToJSON(resourceInfo);

        //    }
        //    return "";
        //}

        //protected string GetMultiResourceInfo(string pathList, string fileStorageName)
        //{

        //    //string fileExtension = Path.GetExtension(fileName);
        //    //string fileID = AppContext.Current.UnitOfData.GetUniId();
        //    //int pathID = fileID.Substring(0, 8).Value<int>();
        //    //string relativePath = Path.Combine(FileManagementUtil.GetRelativePath(fileStorageName, pathID),
        //    //    FileManagementUtil.GetFileName(fileStorageName, fileID, fileExtension));
        //    //string fullPath = new Uri(Path.Combine(FileManagementUtil.GetRootPath(fileStorageName, FilePathScheme.Physical), relativePath)).LocalPath;
        //    //FileManagementUtil.ForeDirectories(FileManagementUtil.GetParentDirectory(fullPath));
        //    //string tempfile = Path.Combine(AppContext.Current.MapPath, Callback.Src(tempPath));

        //    //if (File.Exists(tempfile))
        //    //{
        //    //    File.Copy(tempfile, fullPath, false);
        //    //    File.Delete(tempfile);
        //    //}
        //    if (pathList.IsEmpty())
        //        return "";
        //    var pathArr = pathList.Split(',');
        //    string fileName = "";
        //    List<ResourceInfo> infoList = new List<ResourceInfo>();
        //    pathArr.ToList().ForEach(a =>
        //    {
        //        if (!a.IsEmpty())
        //        {
        //            var path = a.Split('&');
        //            fileName = path[0].Substring(path[0].LastIndexOf('\\') + 1);
        //            string fileID = fileName.Split('.')[0];
        //            string pathID = fileName.Substring(0, 8);
        //            string fileExt = Path.GetExtension(fileName);
        //            var resourceInfo = new ResourceInfo();
        //            resourceInfo.InfoType = ResourceInfoType.Config;
        //            resourceInfo.FileId = fileID;
        //            resourceInfo.PathID = pathID.Value<int>();
        //            resourceInfo.ExtName = fileExt;
        //            resourceInfo.FileNameTitle = path[1];
        //            resourceInfo.FileSizeK = path[2].Value<int>();
        //            resourceInfo.StorageConfigName = fileStorageName;
        //            infoList.Add(resourceInfo);
        //        }
        //    });
        //    //var pathInfo = new FilePathInfo { PathID = pathID.ToString(), FileID = fileID, FileExtension = fileExtension };
        //    return AppContext.Current.FastJson.ToJSON(infoList);
        //}

        public virtual void SetPostDataRow(ObjectData data, DataAction dataAction, string key)
        {
            // throw new NotImplementedException();
            // if(data.)
            if (SingleUploadColumns != null && SingleUploadColumns.Count > 0)
            {
                SingleUploadColumns.ForEach(a =>
                {
                    //if (data.MODEFY_COLUMNS.Contains(a.Name))
                    //{
                    //    string storange = a.Upload.StorageName;
                    //    string fpath = data.Row[a.Name].ToString();
                    //    if (!fpath.IsEmpty())
                    //    {
                    //        ResourceArrange arrange = AppContext.Current.FastJson.ToObject<ResourceArrange>(fpath);
                    //        if (arrange != null)
                    //        {
                    //            arrange.MoveKeyPath(key, storange);
                    //            data.Row[a.Name] = AppContext.Current.FastJson.ToJSON(arrange);
                    //        }
                    //    }
                    //    //data.Row[a.Name] = GetSingleResourceInfo(fpath, a.Upload.StorageName);
                    //}
                });
            }

            if (MultiUploadColumns != null && MultiUploadColumns.Count > 0)
            {
                MultiUploadColumns.ForEach(a =>
                {
                    //if (data.MODEFY_COLUMNS.Contains(a.Name))
                    //{
                    //    string storange = a.Upload.StorageName;
                    //    string fpath = data.Row[a.Name].ToString();
                    //    if (!fpath.IsEmpty())
                    //    {
                    //        ResourceArrange arrange = AppContext.Current.FastJson.ToObject<ResourceArrange>(fpath);
                    //        arrange.MoveKeyPath(key, storange);
                    //        if (arrange != null)
                    //        {
                    //            data.Row[a.Name] = AppContext.Current.FastJson.ToJSON(arrange);
                    //        }
                    //    }
                    //    // data.Row[a.Name] = GetMultiResourceInfo(fpath, a.Upload.StorageName);
                    //}
                });
            }
            if (MomeryColumns != null && MomeryColumns.Count > 0)
            {
                MomeryColumns.ForEach(a =>
                {
                    if (data.MODEFY_COLUMNS.Contains(a.Name))
                    {
                        //string _regname = a.RegName;
                        //IMomery rr = IocContext.Current.FetchInstance<IMomery>(_regname);
                        //rr.AddText(data.Row[a.Name].ToString(), AppContext.Current.UnitOfData);
                    }
                });
            }
        }
        public ActionResult Save(Event updatedEvent, FormCollection formData)
        {
            var action = new DataAction(formData);

            try
            {
                switch (action.Type)
                {
                    case DataActionTypes.Insert: // your Insert logic
                        _db.Events.Add(updatedEvent);
                        break;
                    case DataActionTypes.Delete: // your Delete logic
                        updatedEvent = _db.Events.SingleOrDefault(ev => ev.id == updatedEvent.id);
                        _db.Events.Remove(updatedEvent);
                        break;
                    default:// "update" // your Update logic
                        updatedEvent = _db.Events.SingleOrDefault(
                        ev => ev.id == updatedEvent.id);
                        UpdateModel(updatedEvent);
                        break;
                }
                _db.SaveChanges();
                action.TargetId = updatedEvent.id;
            }
            catch (Exception e)
            {
                action.Type = DataActionTypes.Error;
            }
            return (new AjaxSaveResponse(action));
        }
        /// <summary>
        /// Grabs HTML copied in the clipboard and pastes it into the document (pulls in a copy of embedded content too)
        /// </summary>
        protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
        {
            using (new WaitCursor())
            {
                try
                {
                    // get the list of files from the data meister
                    FileItem[] files = DataMeister.FileData.Files;

                    string[] filePaths = new string[files.Length];
                    // create an array of file entities to insert
                    for (int i = 0; i < files.Length; i++)
                    {
                        filePaths[i] = files[i].ContentsPath;
                    }

                    string html = EditorContext.HtmlGenerationService.GenerateHtmlFromFiles(filePaths);
                    EditorContext.InsertHtml(begin, end, html, null);

                    //place the caret at the end of the inserted content
                    //EditorContext.MoveCaretToMarkupPointer(end, true);
                    return true;
                }
                catch (Exception e)
                {
                    //bugfix 1696, put exceptions into the trace log.
                    Trace.Fail("Exception while inserting HTML: " + e.Message, e.StackTrace);
                    return false;
                }
            }
        }
Exemple #38
0
        public ActionResult Save(Event updatedEvent, FormCollection formData)
        {
            var action = new DataAction(formData);

            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:         // your Insert logic
                    _db.Events.Add(updatedEvent);
                    break;

                case DataActionTypes.Delete:         // your Delete logic
                    updatedEvent = _db.Events.SingleOrDefault(ev => ev.id == updatedEvent.id);
                    _db.Events.Remove(updatedEvent);
                    break;

                default:        // "update" // your Update logic
                    updatedEvent = _db.Events.SingleOrDefault(
                        ev => ev.id == updatedEvent.id);
                    UpdateModel(updatedEvent);
                    break;
                }
                _db.SaveChanges();
                action.TargetId = updatedEvent.id;
            }
            catch (Exception e)
            {
                action.Type = DataActionTypes.Error;
            }
            return(new AjaxSaveResponse(action));
        }
        public ActionResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            var apps = db.Appointments.ToList();
            apps.ToString();

            try
            {
                var changedEvent = DHXEventsHelper.Bind<Appointment>(actionValues);

                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        db.Appointments.Add(new Appointment
                        {

                            Description = changedEvent.Description,
                            StartDate = changedEvent.StartDate,
                            EndDate = changedEvent.EndDate,
                            projectNumber = GlobalVariables.ProjectID_cal

                        });
                        //db.SaveChanges();
                        break;
                    case DataActionTypes.Delete:
                        if (GlobalVariables.role_cal == "Leader") {
                            db.Entry(changedEvent).State = EntityState.Deleted;

                        }
                        else
                        {
                            TempData["notice"] = "Only leader can delete an event.";
                        }

                        break;
                    default:// "update"
                        if (GlobalVariables.role_cal == "Leader")
                        {
                            db.Entry(changedEvent).State = EntityState.Modified;
                        }
                        else
                        {
                            TempData["notice"] = "Only leader can modify an event.";
                        }

                        break;
                }
                db.SaveChanges();
                action.TargetId = changedEvent.Id;
            }
            catch (Exception a)
            {

                System.Console.WriteLine(a);

            }

            return (new AjaxSaveResponse(action));
        }
        public ContentResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            var changedEvent = (ColoredEvent)DHXEventsHelper.Bind(typeof(ColoredEvent), actionValues);
            var color = "";
            if (actionValues["color"] == "#FE7510")
            {
                color = "#FE7510";
            }
            else
            {
                if (changedEvent.start_date < DateTime.Now)
                    color = "#ccc";
                else
                    color = "#76B007";
            }

            CustomFieldsDataContext data = new CustomFieldsDataContext();
            try
            {
                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        changedEvent.color = color;
                        data.ColoredEvents.InsertOnSubmit(changedEvent);
                        break;
                    case DataActionTypes.Delete:
                        changedEvent = data.ColoredEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.ColoredEvents.DeleteOnSubmit(changedEvent);
                        break;
                    default:// "update"
                        var eventToUpdate = data.ColoredEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });

                        changedEvent.color = color;

                        break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            var result = new AjaxSaveResponse(action);
            result.UpdateField("color", color);//property will be updated on the client
            return result;
        }
 protected bool deleteRelated(DataAction action, Recurring changedEvent, SchedulerDataContext context)
 {
     bool finished = false;
     if ((action.Type == DataActionTypes.Delete || action.Type == DataActionTypes.Update) && !string.IsNullOrEmpty(changedEvent.rec_type))
     {
         context.Recurrings.DeleteAllOnSubmit(from ev in context.Recurrings where ev.event_pid == changedEvent.id select ev);
     }
     if (action.Type == DataActionTypes.Delete && changedEvent.event_pid != 0)
     {
         Recurring changed = (from ev in context.Recurrings where ev.id == action.TargetId select ev).Single();
         changed.rec_type = "none";
         finished = true;
     }
     return finished;
 }
Exemple #42
0
        public ActionResult Save(Schedule updatedEvent, FormCollection formData)
        {
            var action = new DataAction(formData);

            var context = new ConferenceManagementContext();

            if (formData["actionButton"] != null)
            {
                try
                {
                    if (formData["actionButton"] == "Save")
                    {
                        if (context.Schedules.SingleOrDefault(ev => ev.ScheduleId == action.SourceId) != null)
                        {
                            var breaktime = context.Schedules.SingleOrDefault(ev => ev.ScheduleId == action.SourceId);
                            TryUpdateModel(updatedEvent);
                        }
                        else
                        {
                            action.Type = DataActionTypes.Insert;
                            var breaktime = new Schedule();
                            breaktime.TopicId = 1;
                            breaktime.StartTime = updatedEvent.StartTime;
                            breaktime.EndDate = updatedEvent.EndDate;
                            breaktime.TopicId = updatedEvent.TopicId;
                            context.Schedules.Add(breaktime);
                        }
                    }
                    else if (formData["actionButton"] == "Delete")
                    {
                        action.Type = DataActionTypes.Delete;
                        updatedEvent = context.Schedules.SingleOrDefault(ev => ev.ScheduleId == updatedEvent.ScheduleId);
                        context.Schedules.Remove(updatedEvent);
                    }
                    context.SaveChanges();
                }
                catch (Exception a)
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }
            return (new SchedulerFormResponseScript(action, updatedEvent));
        }
        public ContentResult CustomFormSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            if (actionValues["actionType"] != null)
            {
                var actionType = actionValues["actionType"].ToLower();
                var data = new DHXSchedulerDataContext();
                try
                {
                    if (actionType == "save")
                    {

                        if (data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId) != null)
                        {
                            //update event
                            var eventToUpdate = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);

                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });

                            action.Type = DataActionTypes.Update;
                        }
                        else
                        {
                            //create event
                            data.ValidEvents.InsertOnSubmit(changedEvent);
                            action.Type = DataActionTypes.Insert;
                        }
                    }
                    else if (actionType == "delete")
                    {

                        changedEvent = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.ValidEvents.DeleteOnSubmit(changedEvent);

                        action.Type = DataActionTypes.Delete;
                    }
                    data.SubmitChanges();
                }

                catch (Exception e)
                {
                    action.Type = DataActionTypes.Error;
                }
            }

            return (new SchedulerFormResponseScript(action, changedEvent));
        }
        /// <summary>
        /// Grabs text copied in the clipboard and pastes it into the document
        /// </summary>
        protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
        {
            try
            {
                // get the text data as a string
                string textData = DataMeister.TextData.Text;
                string html = EditorContext.HtmlGenerationService.GenerateHtmlFromPlainText(textData);

                //insert captured content into the document
                EditorContext.InsertHtml(begin, end, html, null);
                return true;
            }
            catch (Exception e)
            {
                //bugfix 1696, put exceptions into the trace log.
                Trace.Fail("Exception while inserting URL: " + e.Message, e.StackTrace);
                return false;
            }
        }
        public ActionResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            DHXSchedulerModelsDataContext data = new DHXSchedulerModelsDataContext();
            try
            {
                var changedEvent = (Recurring)DHXEventsHelper.Bind(typeof(Recurring), actionValues);
                //operations with recurring events require some additional handling
                bool isFinished = deleteRelated(action, changedEvent, data);
                if (!isFinished)
                {
                    switch (action.Type)
                    {

                        case DataActionTypes.Insert:
                            data.Recurrings.InsertOnSubmit(changedEvent);
                            if (changedEvent.rec_type == "none")//delete one event from the serie
                                action.Type = DataActionTypes.Delete;
                            break;
                        case DataActionTypes.Delete:
                            changedEvent = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                            data.Recurrings.DeleteOnSubmit(changedEvent);
                            break;
                        default:// "update"
                            var eventToUpdate = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                            break;
                    }
                }
                data.SubmitChanges();

                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return (new AjaxSaveResponse(action));
        }
        public ActionResult CustomSave(Event changedEvent, FormCollection actionValues)
        {
            var action = new DataAction(DataActionTypes.Update, changedEvent.id, changedEvent.id);
            if (actionValues["actionButton"] != null)
            {
                DHXSchedulerDataContext data = new DHXSchedulerDataContext();
                try
                {
                    if (actionValues["actionButton"] == "Save")
                    {

                        if (data.Events.SingleOrDefault(ev => ev.id == action.SourceId) != null)
                        {
                            var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                        }
                        else
                        {
                            action.Type = DataActionTypes.Insert;
                            data.Events.InsertOnSubmit(changedEvent);
                        }
                    }else if(actionValues["actionButton"] == "Delete"){
                        action.Type = DataActionTypes.Delete;
                        changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                    }
                    data.SubmitChanges();
                }

                catch (Exception e)
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }

            return (new SchedulerFormResponseScript(action, changedEvent));
        }
        public void ProcessRequest(HttpContext context)
        {
            var action = new DataAction(context.Request.Form);
            var data = new SchedulerDataContext();

            try
            {

                var changedEvent = (Recurring)DHXEventsHelper.Bind(typeof(Recurring), context.Request.Form);//create model object from the request fields

                bool isFinished = deleteRelated(action, changedEvent, data);
                if (!isFinished)
                {
                    switch (action.Type)
                    {
                        case DataActionTypes.Insert: // define here your Insert logic
                            data.Recurrings.InsertOnSubmit(changedEvent);

                            break;
                        case DataActionTypes.Delete: // define here your Delete logic
                            changedEvent = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                            data.Recurrings.DeleteOnSubmit(changedEvent);
                            break;
                        default:// "update" // define here your Update logic
                            var updated = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId);
                            DHXEventsHelper.Update(updated, changedEvent, new List<string>() { "id" });

                            break;
                    }
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
                action = insertRelated(action, changedEvent, data);
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            context.Response.ContentType = "text/xml";
            context.Response.Write(new AjaxSaveResponse(action).ToString());
        }
        public ContentResult Save(int? id, FormCollection actionValues)
        {
           
            var action = new DataAction(actionValues);
          //  DHXSchedulerDataItem data = new DHXSchedulerDataItem();
         //   CalendarDataContext data = new CalendarDataContext();
            var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);
            
            var data = new CalendarDataContext();
            try
            {                
                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        //do insert

                        //action.TargetId = changedEvent.id;//assign postoperational id
                        changedEvent.LecturerId = "IT14121548";           
                        data.Events.InsertOnSubmit(changedEvent);
                        break;
                    case DataActionTypes.Delete:
                        //do delete
                        changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                        break;
                    default:// "update"                          
                            //do update
                        var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });//update all properties, except for id
                        break;
                }
                                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch(Exception e)
            {
                action.Type = DataActionTypes.Error;
            }
            return (ContentResult)new AjaxSaveResponse(action);
        }
        public ContentResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);
            DHXSchedulerModelsDataContext data = new DHXSchedulerModelsDataContext();
            if (this.Request.IsAuthenticated && changedEvent.user_id == data.UserDetails.SingleOrDefault(u => u.UserName == this.HttpContext.User.Identity.Name).UserId)
            {

                try
                {
                    switch (action.Type)
                    {
                        case DataActionTypes.Insert:
                            changedEvent.room_id = data.Rooms.First().key;
                            data.Events.InsertOnSubmit(changedEvent);
                            break;
                        case DataActionTypes.Delete:
                            changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                            data.Events.DeleteOnSubmit(changedEvent);
                            break;
                        default:// "update"
                            var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                            break;
                    }
                    data.SubmitChanges();
                    action.TargetId = changedEvent.id;
                }
                catch
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }
            return (new AjaxSaveResponse(action));
        }
        public ContentResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            var changedEvent = DHXEventsHelper.Bind<Event>(actionValues);

            if (this.Request.IsAuthenticated && changedEvent.user_id == (Guid)Membership.GetUser().ProviderUserKey)
            {
                DHXSchedulerDataContext data = new DHXSchedulerDataContext();
                try
                {
                    switch (action.Type)
                    {
                        case DataActionTypes.Insert:
                            changedEvent.room_id = data.Rooms.First().key;
                            data.Events.InsertOnSubmit(changedEvent);
                            break;
                        case DataActionTypes.Delete:
                            changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                            data.Events.DeleteOnSubmit(changedEvent);
                            break;
                        default:// "update"
                            var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                            DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                            break;
                    }
                    data.SubmitChanges();
                    action.TargetId = changedEvent.id;
                }
                catch (Exception a)
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }
            return (new AjaxSaveResponse(action));
        }
Exemple #51
0
        public void ProcessRequest(HttpContext context)
        {
            var action = new DataAction(context.Request.Form);
            var data = new SchedulerDataContext();

            try
            {

                var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), context.Request.Form);//create event object from request

                switch (action.Type)
                {
                    case DataActionTypes.Insert: // define here your Insert logic
                        data.Events.InsertOnSubmit(changedEvent);

                        break;
                    case DataActionTypes.Delete: // define here your Delete logic
                        changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        data.Events.DeleteOnSubmit(changedEvent);
                        break;
                    default:// "update" // define here your Update logic
                        var updated = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
                        //update "updated" object by changedEvent's values, 'id' should remain unchanged
                        DHXEventsHelper.Update(updated, changedEvent, new List<string>() { "id" });
                        break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            context.Response.ContentType = "text/xml";
            context.Response.Write(new AjaxSaveResponse(action).ToString());
        }
Exemple #52
0
        public ContentResult Save(int? id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            var changedEvent = (ColoredEvent)DHXEventsHelper.Bind(typeof(ColoredEvent), actionValues);

            try
            {
                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        if (!Repository.CreateColoredEvent(changedEvent))
                        {
                            Repository.UpdateColoredEvent(changedEvent);
                        }
                        break;
                    case DataActionTypes.Delete:
                        if (!Repository.RemoveColoredEvent((int)action.SourceId))
                        {
                            Repository.UpdateColoredEvent(changedEvent);
                        }
                        break;
                    default:// "update"
                        var eventToUpdate = Repository.ColoredEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                        if (!Repository.UpdateColoredEvent(changedEvent))
                        {
                            Repository.UpdateColoredEvent(changedEvent);
                        }
                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string> { "id" });
                        break;
                }
                //data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return (new AjaxSaveResponse(action));
        }
Exemple #53
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="changedEvent"></param>
        /// <param name="actionValues"></param>
        /// <returns></returns>
        public ContentResult NativeSave(CalendarEvent changedEvent, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            string currentUser = HttpContext.User.Identity.Name;
            try
            {
                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        if (!CheckStartDateAndEndDateInRoom(changedEvent.room_id, changedEvent.start_date, changedEvent.end_date))
                        {
                            action.Type = DataActionTypes.Delete;
                            action.Message = "Time check faild!";
                        }
                        else
                        {
                            if (!CheckTimeCurrent(changedEvent.start_date))
                            {
                                action.Type = DataActionTypes.Delete;
                                action.Message = "Time check faild!";
                            }
                            else
                            {
                                try
                                {
                                    if (changedEvent.laptop_id == "NotUse")
                                        changedEvent.laptop_id = null;

                                    if (changedEvent.phone_id == "NotUse")
                                        changedEvent.phone_id = null;

                                    if (changedEvent.projector_id == "NotUse")
                                        changedEvent.projector_id = null;

                                    if (User.IsInRole("GA"))
                                        changedEvent.for_dept = "GA";

                                    if (User.IsInRole("Employee"))
                                        changedEvent.for_dept = "Employee";


                                    changedEvent.user_name = HttpContext.User.Identity.Name;
                                    changedEvent.creator_id = Guid.Parse(HttpContext.User.Identity.GetUserId());

                                    if (changedEvent.projector_id != null)
                                    {
                                        if (!CheckProjectorExitsInRoom(changedEvent.room_id))
                                        {
                                            action.Type = DataActionTypes.Error;
                                            action.Message = "Current rooms were installed the projector!";
                                        }
                                        else
                                        {
                                            if (!Repository.Insert(changedEvent))
                                            {
                                                action.Type = DataActionTypes.Error;
                                                action.Message = "Create faild!";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!Repository.Insert(changedEvent))
                                        {
                                            action.Type = DataActionTypes.Error;
                                            action.Message = "Create faild!";
                                        }
                                    }

                                }
                                catch (Exception ex)
                                {
                                    action.Type = DataActionTypes.Error;
                                    action.Message = ex.Message;
                                }
                            }

                        }
                        break;
                    case DataActionTypes.Delete:
                        changedEvent = Repository.GetAll<CalendarEvent>().SingleOrDefault(ev => ev.id == action.SourceId);
                        if (changedEvent != null)
                        {
                            if (changedEvent.user_name == currentUser)
                            {
                                try
                                {
                                    if (!Repository.Delete(changedEvent))
                                    {
                                        action.Type = DataActionTypes.Error;
                                        action.Message = "Delete";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    action.Type = DataActionTypes.Error;
                                    action.Message = ex.Message;
                                }
                            }
                            else
                            {
                                action.Type=DataActionTypes.Error;
                                action.Message = "You can not delete, only the creator can delete!";
                            }
                            
                        }
                        else
                        {
                            action.Type = DataActionTypes.Error;
                            action.Message = "Event id notfound!";
                        }
                        break;
                    default:// "update"                          
                        var eventToUpdate = Repository.GetAll<CalendarEvent>().SingleOrDefault(ev => ev.id == action.SourceId);
                        if (eventToUpdate != null)
                        {
                            if (eventToUpdate.user_name == currentUser)
                            {
                                if (!CheckTimeCurrent(changedEvent.start_date))
                                {
                                    action.Type = DataActionTypes.Error;
                                    action.Message = "Time check!";
                                }
                                else
                                {
                                    if (changedEvent.projector_id == "null")
                                    {
                                        changedEvent.projector_id = null;
                                    }
                                    if (changedEvent.laptop_id == "null")
                                    {
                                        changedEvent.laptop_id = null;
                                    }
                                    if (changedEvent.phone_id == "null")
                                    {
                                        changedEvent.phone_id = null;
                                    }
                                    changedEvent.creator_id = Guid.Parse(HttpContext.User.Identity.GetUserId());
                                    changedEvent.user_name = HttpContext.User.Identity.Name;
                                    try
                                    {
                                        if (!Repository.UpdateEvents(changedEvent))
                                        {
                                            action.Type = DataActionTypes.Error;
                                            action.Message = "Update";
                                        }
                                        DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" });
                                    }
                                    catch (Exception ex)
                                    {
                                        action.Type = DataActionTypes.Error;
                                        action.Message = ex.Message;
                                    }
                                }
                            }
                            else
                            {
                                action.Type = DataActionTypes.Error;
                                action.Message = "You can not fix, only the creator can edit!";
                            }
                        }
                        break;
                }
                if (changedEvent != null)
                    action.TargetId = changedEvent.id;
            }
            catch(Exception ex)
            {
                action.Type = DataActionTypes.Error;
                action.Message = ex.Message;
            }

            return (new AjaxSaveResponse(action));
        }
 /// <summary>
 /// Notify the data format handler that data was dropped and should be inserted into
 /// the document at whatever insert location the handler has internally tracked.
 /// </summary>
 /// <param name="action"></param>
 public abstract bool DataDropped(DataAction action);
 /// <summary>
 /// Instruct the handler to insert data.
 /// </summary>
 public abstract bool InsertData(DataAction action, params object[] args);
        /// <summary>
        /// Grabs HTML copied in the clipboard and pastes it into the document (pulls in a copy of embedded content too)
        /// </summary>
        protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
        {
            using (new WaitCursor())
            {
                try
                {
                    //StringBuilder html = new StringBuilder();
                    //html.AppendFormat("<a href=\"{0}\">{1}</a>", DataMeister.URLData.URL, DataMeister.URLData.Title);
                    string html = EditorContext.HtmlGenerationService.GenerateHtmlFromLink(Url, Title, Title, String.Empty, false);
                    EditorContext.InsertHtml(begin, end, html, null);

                    //place the caret at the end of the inserted content
                    //EditorContext.MoveCaretToMarkupPointer(end, true);
                    return true;
                }
                catch (Exception e)
                {
                    //bugfix 1696, put exceptions into the trace log.
                    Trace.Fail("Exception while inserting URL: " + e.Message, e.StackTrace);
                    return false;
                }
            }
        }
        /// <summary>
        /// ���ݶ����ı䴦��
        /// </summary>
        /// <param name="e"></param>
        protected virtual void DoActionChanged(DataAction action)
        {
            // ��ֹ���а�ť
            foreach (Control con in pnlBottom.Controls)
            {
                if (con is Button)
                {
                    Button btn = con as Button;
                    btn.Enabled = false;
                }
            }

            switch (action)
            {
                case DataAction.Add:
                    btnSave.Enabled = true;
                    btnCancel.Enabled = true;
                    break;
                case DataAction.Edit:
                    btnSave.Enabled = true;
                    btnCancel.Enabled = true;
                    break;
                case DataAction.Audit:
                    break;
                case DataAction.Delete:
                    btnNew.Enabled = RightInfo.HasRight(CurrentModule.ModuleCode, CurrentModule.ModuleName, "���", "���").Equals("");
                    break;
                case DataAction.Print:
                    break;
                default:
                    btnEdit.Enabled = FirstEdit.HasData && !State.Equals("1") && RightInfo.HasRight(CurrentModule.ModuleCode, CurrentModule.ModuleName, "�༭", "�༭").Equals("");  // ��˺󲻿��޸�
                    btnNew.Enabled = !FirstEdit.HasData && RightInfo.HasRight(CurrentModule.ModuleCode, CurrentModule.ModuleName, "���", "���").Equals("");
                    btnAudit.Enabled = FirstEdit.HasData && RightInfo.HasRight(CurrentModule.ModuleCode, CurrentModule.ModuleName, "��", "��").Equals("");
                    btnPrint.Enabled = btnEdit.Enabled && RightInfo.HasRight(CurrentModule.ModuleCode, CurrentModule.ModuleName, "��ӡ", "��ӡ").Equals("");
                    btnDel.Enabled = FirstEdit.HasData && !State.Equals("1") && RightInfo.HasRight(CurrentModule.ModuleCode, CurrentModule.ModuleName, "ɾ��", "ɾ��").Equals("");
                    break;
            }
        }
 /// <summary>
 /// �ı�����Ĭ�϶�������Ĭ���Ǹı䴰����EditList�б�������пؼ�
 /// ���������Ҫ��ͬ������дЩ����
 /// </summary>
 /// <param name="action"></param>
 protected virtual void DoChangeAction(DataAction action)
 {
     // �ı�ÿ���ؼ���״̬
     foreach (ILLUCEdit edit in EditList)
     {
         edit.Action = action;
     }
 }
 public ActionResult Save(int? id, FormCollection actionValues)
 {
     var action = new DataAction(actionValues);
     var changedEvent = DHXEventsHelper.Bind<Event>(actionValues);
     if (action.Type != DataActionTypes.Error)
     {
         //process resize, d'n'd operations...
         return NativeSave(changedEvent, actionValues);
     }
     else
     {
         //custom form operation
         return CustomSave(changedEvent, actionValues);
     }
 }
 protected DataAction insertRelated(DataAction action, Recurring changedEvent, SchedulerDataContext context)
 {
     if (action.Type == DataActionTypes.Insert && changedEvent.rec_type == "none")
     {//insert_related
          action.Type = DataActionTypes.Delete;
     }
     return action;
 }