Esempio n. 1
0
        public AbstractCalendarEntryViewModel Create(EventTemplate eventTemplate, string simulatorName, bool useCalendarEventNames, bool autoReplaceKnownTracks)
        {
            if (!string.IsNullOrEmpty(simulatorName) && autoReplaceKnownTracks && _trackTemplateToSimTrackMapper.TryGetSimulatorTrackName(simulatorName, eventTemplate.TrackTemplate.TrackName, out string simulatorTrackName))
            {
                Track trackDefinition = _simulatorContentController.GetAllTracksForSimulator(simulatorName).FirstOrDefault(x => x.Name == simulatorTrackName);
                if (trackDefinition != null)
                {
                    var newEntry = _viewModelFactory.Create <ExistingTrackCalendarEntryViewModel>();
                    newEntry.CustomEventName = useCalendarEventNames ? eventTemplate.EventName : string.Empty;
                    newEntry.TrackName       = simulatorTrackName;
                    newEntry.LayoutLength    = trackDefinition.LapDistance;
                    bool hasMap = _mapsLoader.TryLoadMap(simulatorName, simulatorTrackName, out TrackMapDto trackMapDto);
                    if (hasMap)
                    {
                        newEntry.TrackGeometryViewModel.FromModel(trackMapDto.TrackGeometry);
                    }

                    return(newEntry);
                }
            }
            return(new CalendarPlaceholderEntryViewModel()
            {
                CustomEventName = useCalendarEventNames ? eventTemplate.EventName : string.Empty,
                LayoutLength = eventTemplate.TrackTemplate.LayoutLength,
                TrackName = eventTemplate.TrackTemplate.TrackName,
            });
        }
        public ActionResult ProjectEventPaymentGenerator(int RepperID, int BudgetID)
        {
            if (RepperID > 0 && BudgetID > 0)
            {
                ReportPeriodListR repper = GetRepper(RepperID, BudgetID);

                ProjectEventService pes = new ProjectEventService();
                ProjectEvent        o   = new ProjectEvent();
                o.CompletedDate    = repper.PaymentDate;
                o.EventDescription = "Payment Request";
                o.ProjectID        = BudgetID;
                //o.EventType = GetPaymentEventType();
                o.EventTypeID    = GetPaymentEventType().EventTypeID;
                o.ReportPeriodID = RepperID;
                o.SSPOrGrantee   = true;
                o.EventStatus    = 0;
                pes.Insert(o);

                EventTemplate   eh = new EventTemplate();
                TemplateService ts = new TemplateService();

                TemplateDocument td1 = null;
                td1 = ts.GetTemplateDocument("Запрос на Оплату");
                if (td1 != null)
                {
                    eh.CreateFromTemplate(td1.TemplateDocsID, BudgetID, o.EventID, RepperID);
                }
            }

            return(RedirectToAction("Reppers", new { id = BudgetID }));
        }
 /// <summary>
 /// 更新事件模板{事件模板}对象(即:一条记录
 /// </summary>
 public int Update(EventTemplate eventTemplate)
 {
     using (var dbContext = UnitOfWork.Get(Unity.ContainerName))
     {
         return(new EventTemplateRepository(dbContext).Update(eventTemplate));
     }
 }
Esempio n. 4
0
        public static EventModel LoadEventByID(long EventID)
        {
            var _event = _DL.Events.Get.ByID(EventID);
            //
            var _eventModel = new EventModel();
            //
            Dictionary <string, string> dic = _event.Content.DocumentElement.SelectNodes("keys/key").Cast <XmlElement>()
                                              .ToDictionary(n => n.GetAttribute("name"), n => n.GetAttribute("value"));

            //
            _eventModel.Init(_event.Type.Type);
            // Add ApplicationID
            if (dic.Where(a => a.Key == "ApplicationID").Count() <= 0 && dic.Where(a => a.Key == "TagID").Count() > 0)
            {
                string TagID = dic.Where(a => a.Key == "TagID").Select(a => a.Value).First();
                var    tag   = _DL.Tag.Get.ByID(long.Parse(TagID ?? "0"));
                if (tag != null)
                {
                    dic.Add("ApplicationID", tag.ApplicationID.ToString());
                }
            }
            //
            var keys = _eventModel.CheckKeys(dic);

            //
            _eventModel.FieldModel(keys);
            //
            _eventModel.Thumbnail = EventTemplate.GetThumbnail(_eventModel.Models, _eventModel.Type);
            //
            _eventModel.Content = EventTemplate.GetContent(keys, _eventModel.Type);
            //
            _eventModel.EventID = EventID;
            //
            return(_eventModel);
        }
Esempio n. 5
0
        void LoadTemplate()
        {
            this.EventTemplateList = new List <EventTemplate>();

            string configFilename = U.ConfigDataFilename("template_list_event_");

            if (!File.Exists(configFilename))
            {
                return;
            }
            string[] lines = File.ReadAllLines(configFilename);
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];
                if (U.OtherLangLine(line))
                {
                    continue;
                }
                string[] sp = line.Split('\t');
                if (sp.Length < 2)
                {
                    continue;
                }
                EventTemplate et = new EventTemplate();
                et.Filename = sp[0];
                et.Info     = sp[1];

                this.EventTemplateList.Add(et);
                this.TemplateListbox.Items.Add(et.Info);
            }
        }
Esempio n. 6
0
        public EventModel(Dictionary <string, string> dic, EN_EventType Type)
        {
            if (!EventTemplate.HasTemplate(Type))
            {
                throw new ExodusException("Template not found");
            }
            //
            Init(Type);
            // check keys
            var keys = CheckKeys(dic);

            // fill model
            FieldModel(keys);
            // Get Content
            Content = EventTemplate.GetContent(keys, Type);
            // Get ThumbNail
            Thumbnail = EventTemplate.GetThumbnail(Models, Type);
            // Add Event
            EventID = _DL.Events.Add.Event(this.Event);
            // Add Relations
            if (this.EventID != -1)
            {
                _DL.Events.Add.EventToUsers(this.EventID, RelatedUsers);
            }
        }
Esempio n. 7
0
 public CustomEventOccurredInfo(IResource resource, EventTemplate eventTemplate, Func <Session, bool> receivers, object issuer, object value)
 {
     Resource      = resource;
     EventTemplate = eventTemplate;
     Receivers     = receivers;
     Issuer        = issuer;
     Value         = value;
 }
Esempio n. 8
0
        /// <summary>
        /// This method will call the event of the clicked item
        /// </summary>
        /// <param name="id">The id used to identify the clicked object</param>
        public static void HandleEvent(string id)
        {
            EventTemplate tmpEvent = GetEventById(id);

            if (tmpEvent != null)
            {
                tmpEvent.OnClick();
            }
        }
Esempio n. 9
0
        private void TemplateList_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = this.TemplateListbox.SelectedIndex;

            if (index < 0 || index >= this.EventTemplateList.Count)
            {
                return;
            }
            EventTemplate et = this.EventTemplateList[index];

            SelectFilename.Text = et.Filename;
            LoadCodes(et);
        }
Esempio n. 10
0
    public void CreateEvent(string eventMessage, Color textColour)
    {
        currentDeleteTime = maxTimeDelete;
        EventTemplate newEvent = Instantiate(eventTemplatePrefab, transform).GetComponent <EventTemplate>();



        currEvents.Add(newEvent);
        newEvent.SetUpEventTemplate(eventMessage, textColour);
        currNumEvents = currEvents.Count;
        StopCoroutine(ClearList());
        newEvent.transform.position = SetEventPosition(newEvent.rt.rect.height, newEvent.rt);
    }
Esempio n. 11
0
        public string Render()
        {
            List <string> stringList = new List <string>();

            if (!string.IsNullOrEmpty(this.Id))
            {
                stringList.Add("\"id\":\"" + this.Id + "\"");
            }
            if (!string.IsNullOrEmpty(this.Label))
            {
                stringList.Add("\"label\":\"" + this.Label + "\"");
            }
            if (this.Width != 0)
            {
                stringList.Add("\"width\":" + this.Width.ToString());
            }
            if (this.Align != GridViewColumn.Aligns.Center)
            {
                stringList.Add("\"align\":\"" + Enum.GetName(typeof(GridViewColumn.Aligns), (object)this.Align).ToLower() + "\"");
            }
            if (this.VAlign != GridViewColumn.VAligns.Top)
            {
                stringList.Add("\"valign\":\"" + Enum.GetName(typeof(GridViewColumn.VAligns), (object)this.VAlign).ToLower() + "\"");
            }
            if (!string.IsNullOrEmpty(this.Template))
            {
                stringList.Add("\"template\":" + EventTemplate.Render(this.Template));
            }
            if (this.Sorting != GridViewColumn.Sort.String)
            {
                string str = (string)null;
                if (this.Sorting == GridViewColumn.Sort.String)
                {
                    str = "\"str\"";
                }
                else if (this.Sorting == GridViewColumn.Sort.Number)
                {
                    str = "\"int\"";
                }
                else if (this.Sorting == GridViewColumn.Sort.Date)
                {
                    str = "\"date\"";
                }
                else if (!string.IsNullOrEmpty(this._sort))
                {
                    str = this._sort;
                }
                stringList.Add("\"sort\":" + str);
            }
            return("{" + string.Join(",", stringList.ToArray()) + "}");
        }
Esempio n. 12
0
    public AsyncReply Unlisten(EventTemplate et)
    {
        if (et == null)
        {
            return(new AsyncReply().TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.MethodNotFound, "")));
        }

        if (!et.Listenable)
        {
            return(new AsyncReply().TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.NotListenable, "")));
        }

        return(connection.SendUnlistenRequest(instanceId, et.Index));
    }
Esempio n. 13
0
 private void RunEvent(EventTemplate statement)
 {
     foreach (ILink link in Links)
     {
         if (link is EventLink)
         {
             if (((EventLink)link).Name == statement.Name)
             {
                 ((EventLink)link).Expressions.Add(statement.Expressions);
                 ((EventLink)link).ExecutRequest += ClassInterpretor_ExecutRequest;
                 return;
             }
         }
     }
 }
Esempio n. 14
0
        protected List <DTO_KeyItem> CheckKeys(Dictionary <string, string> dic)
        {
            List <string>      incorrectKeys = new List <string>();
            List <DTO_KeyItem> keys          = EventTemplate.CheckContentKeys(dic, Type, out incorrectKeys);

            // If error
            if (incorrectKeys.Count > 0)
            {
                throw new ApiEventTempleteIncorrectKeys($"Incorrent Keys: " + string.Join(",", incorrectKeys));
            }
            else
            {
                return(keys);
            }
        }
        public async Task <IActionResult> Create([Bind("SequentialNumber,Description")] EventTemplate eventTemplate)
        {
            if (ModelState.IsValid)
            {
                var eventTemplates = await _context.EventTemplates.ToListAsync();

                eventTemplates.ForEach(x => x.SequentialNumber += x.SequentialNumber >= eventTemplate.SequentialNumber ? +1 : 0);
                _context.UpdateRange(eventTemplates);
                _context.Add(eventTemplate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ModelState.AddModelError("", "Описание мероприятия должно содержать от 5 до 150 символов");
            return(await Index(eventTemplate));
        }
Esempio n. 16
0
        void LoadCodes(EventTemplate et)
        {
            this.Codes = new List <EventScript.OneCode>();

            string fullfilename = Path.Combine(Program.BaseDirectory, "config", "data", et.Filename);

            if (!File.Exists(fullfilename))
            {
                return;
            }

            string XXXXXXXX = null;
            string YYYYYYYY = null;

            if (et.Filename.IndexOf("template_event_CALL_END_EVENT") >= 0)
            {
                XXXXXXXX = ToPointerToString(EventCondForm.GetEndEvent(this.MapID));
            }
            else if (et.Filename.IndexOf("template_event_PREPARATION") >= 0)
            {
                XXXXXXXX = ToPointerToString(EventCondForm.GetPlayerUnits(this.MapID));
                YYYYYYYY = ToPointerToString(EventCondForm.GetEnemyUnits(this.MapID));
            }
            else if (et.Filename.IndexOf("_COND_") >= 0)
            {
                uint labelX = GetUnuseLabelID(0x9000);
                XXXXXXXX = ToUShortToString(labelX);

                uint labelY = GetUnuseLabelID(labelX + 1);
                YYYYYYYY = ToUShortToString(labelY);
            }


            byte[] bin = EventScriptInnerControl.ConverteventTextToBin(fullfilename
                                                                       , EventScriptInnerControl.TermCode.NoTerm
                                                                       , XXXXXXXX, YYYYYYYY);
            uint addr  = 0;
            uint limit = (uint)bin.Length;

            while (addr < limit)
            {
                EventScript.OneCode code = Program.EventScript.DisAseemble(bin, addr);
                this.Codes.Add(code);
                addr += (uint)code.Script.Size;
            }
            this.SampleEventListbox.DummyAlloc(this.Codes.Count, 0);
        }
Esempio n. 17
0
        private Hashtable genEventTemplates(String subfile)
        {
            Hashtable ret  = new Hashtable();
            String    path = Application.StartupPath + "\\events\\" + subfile;

            try
            {
                if (System.IO.File.Exists(path))
                {
                    string[] lines = File.ReadAllLines(path);
                    for (int j = 0; j < lines.Length; j++)
                    {
                        string line = lines[j].Trim();
                        if (!lines[j].StartsWith("#"))
                        {
                            string[]      columns = line.Split(new char[] { '|' });
                            EventTemplate et      = new EventTemplate(subfile, columns);
                            javax.microedition.lcdui.Image icon = (javax.microedition.lcdui.Image)Images[et.imageKey];
                            if (icon == null && et.imageKey.Length > 0)
                            {
                                try
                                {
                                    icon = new javax.microedition.lcdui.Image(
                                        Image.FromFile(Application.StartupPath + "\\events\\" + et.imageKey)
                                        );
                                    imageList1.Images.Add(et.imageKey, icon.dimg);
                                }
                                catch (Exception err)
                                {
                                }
                            }
                            et.icon      = icon;
                            ret[et.name] = et;
                        }
                        else
                        {
                            // this line is comment
                        }
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message + "\n" + path);
            }
            return(ret);
        }
Esempio n. 18
0
        private static void ValidateEventTemplate(ScheduleTemplate s, EventTemplate e, List <ScheduleGenerateError> errors)
        {
            if (e.Order > s.RegularScheduleTime.Count)
            {
                errors.Add(ScheduleGenerateError.NoScheduleForEvent);
            }

            if (e.CategoryIndex < 0 || e.CategoryIndex >= s.CategoryNames.Count)
            {
                errors.Add(ScheduleGenerateError.NoCategoryForEvent);
            }

            errors.AddRange(from organizerIndex in e.OrganizerIndexes
                            where organizerIndex < 0 || organizerIndex >= s.Persons.Count
                            select ScheduleGenerateError.NoPersonForEventOrganizer);

            errors.AddRange(from participantIndex in e.ParticipantsIndexes
                            where participantIndex < 0 || participantIndex >= s.Persons.Count
                            select ScheduleGenerateError.NoPersonForEventParticipant);
        }
Esempio n. 19
0
        public override IEnumerable <IModObject> Load(Mod mod)
        {
            foreach (var rec in DataFile.Records)
            {
                var et = new EventTemplate();
                et.TemplateParameters = rec.Parameters;
                mod.EventTemplates.Add(et);

                et.ModID              = rec.Get <string>("ID", et);
                et.Type               = mod.EventTypes.FindByName(rec.Get <string>("Type", et));
                et.Severity           = rec.Get <EventSeverity>("Severity", et);
                et.EffectAmount       = rec.Get <int>("Effect Amount", et);
                et.MessageTarget      = rec.Get <EventMessageTarget>("Message To", et);
                et.OccurrenceMessages = LoadMessages(rec, et, "Message").ToList();
                et.Picture            = rec.Get <string>("Picture", et);
                et.TimeTillCompletion = rec.Get <int>("Time Till Completion", et);
                et.WarningMessages    = LoadMessages(rec, et, "Start Message").ToList();

                yield return(et);
            }
        }
Esempio n. 20
0
 private IEnumerator ClearList()
 {
     while (currNumEvents > 0)
     {
         List <EventTemplate> eventsCopy = new List <EventTemplate>();
         eventsCopy.AddRange(currEvents);
         EventTemplate eventDisplay = eventsCopy[0];
         eventsCopy.Remove(eventDisplay);
         Destroy(eventDisplay.gameObject);
         currEvents.Clear();
         for (int i = 0; i < eventsCopy.Count; i++)
         {
             if (eventsCopy[i])
             {
                 currEvents.Add(eventsCopy[i]);
             }
         }
         currNumEvents--;
         RefreshPositions();
         yield return(new WaitForSeconds(timeBetweenClearing));
     }
 }
Esempio n. 21
0
        /// <summary>
        /// Loads event messages from a record.
        /// </summary>
        /// <param name="rec"></param>
        public static IEnumerable <EventMessage> LoadMessages(Record rec, EventTemplate et, string prefix)
        {
            int count = 0;
            int index = -1;

            while (true)
            {
                count++;

                var m = new EventMessage();

                var titleField = rec.FindField(new string[]
                {
                    $"{prefix} Title {count}",
                    $"{prefix} Title"
                }, ref index, false, index + 1);
                if (titleField == null)
                {
                    break;                     // no more messages
                }
                var title = titleField.CreateFormula <string>(et);

                var textField = rec.FindField(new string[]
                {
                    $"{prefix} {count}",
                    $"{prefix}"
                }, ref index, false, index + 1);
                if (textField == null)
                {
                    break;                     // no more messages
                }
                var text = textField.CreateFormula <string>(et);

                yield return(new EventMessage {
                    Title = title, Text = text
                });
            }
        }
        public ActionResult ProjectEventAcceptanceMemoGenerator(int RepperID, int BudgetID)
        {
            if (RepperID > 0 && BudgetID > 0)
            {
                ReportPeriodListR repper = GetRepper(RepperID, BudgetID);

                //Create Event.
                ProjectEventService pes = new ProjectEventService();
                ProjectEvent        o   = new ProjectEvent();
                o.CompletedDate    = repper.PaymentDate;
                o.EventDescription = "Letter to Grantee";
                o.ProjectID        = BudgetID;
                //o.EventType = GetPaymentEventType();
                o.EventTypeID    = GetPaymentEventType().EventTypeID;
                o.ReportPeriodID = RepperID;
                o.SSPOrGrantee   = true;
                o.EventStatus    = 0;

                pes.Insert(o);

                EventTemplate   eh = new EventTemplate();
                TemplateService ts = new TemplateService();

                //Generate Document.
                TemplateDocument td1 = null;
                td1 = ts.GetTemplateDocument("письмо о принятии отчета");
                if (td1 != null)
                {
                    eh.CreateFromTemplate(td1.TemplateDocsID, BudgetID, o.EventID, RepperID);
                }
            }

            return(RedirectToAction("Index", "Events", null));

            // return RedirectToAction("Reppers", new { id = BudgetID });
        }
Esempio n. 23
0
        private void AddBody(Document document, ReportModel model)
        {
            var generalSum = 0.0M;

            if (model.MaterialAidEmployees.Any())
            {
                var template = new MaterialAidTemplate(_pdfHelper, document, model.MaterialAidEmployees);
                template.CreateBody();
                template.AddSum();

                generalSum += template.GeneralSum;
            }

            if (model.AwardEmployees.Any())
            {
                var template = new AwardTemplate(_pdfHelper, document, model.AwardEmployees);
                template.CreateBody();
                template.AddSum();

                generalSum += template.GeneralSum;
            }

            if (model.CulturalEmployees.Any())
            {
                var template = new CulturalTemplate(_pdfHelper, document, model.CulturalEmployees);
                template.CreateBody();
                template.AddSum();

                generalSum += template.GeneralSum;
            }

            if (model.EventEmployees.Any(x => x.TypeEvent == TypeEvent.Travel))
            {
                var template = new EventTemplate(_pdfHelper, document, model.EventEmployees.Where(x => x.TypeEvent == TypeEvent.Travel));
                template.CreateBody();
                template.AddSum();

                generalSum += template.GeneralSum;
            }

            if (model.EventEmployees.Any(x => x.TypeEvent == TypeEvent.Wellness))
            {
                var template = new EventTemplate(_pdfHelper, document, model.EventEmployees.Where(x => x.TypeEvent == TypeEvent.Wellness));
                template.CreateBody();
                template.AddSum();

                generalSum += template.GeneralSum;
            }

            if (model.EventEmployees.Any(x => x.TypeEvent == TypeEvent.Tour))
            {
                var template = new EventTemplate(_pdfHelper, document, model.EventEmployees.Where(x => x.TypeEvent == TypeEvent.Tour));
                template.CreateBody();
                template.AddSum();

                generalSum += template.GeneralSum;
            }

            if (model.GiftEmployees.Any())
            {
                var template = new GiftTemplate(_pdfHelper, document, model.GiftEmployees);
                template.CreateBody();
                template.AddSum();

                generalSum += template.GeneralSum;
            }

            if (model.TypeReport == TypeReport.All)
            {
                _pdfHelper.AddEmptyParagraph(document, 2);
                document.Add(_pdfHelper.AddParagraph($"Cумма - {generalSum} {_pdfHelper.Сurrency}", Element.ALIGN_RIGHT));
            }

            _pdfHelper.AddEmptyParagraph(document, 2);
        }
        public ActionResult SelectTemplate(int TemplateDocsID, int ProjectID, int EventID, int?ReportPeriodID)
        {
            if (Session["ProposalID"] == null)
            {
                return(RedirectToAction("Search", "ProposalInfo"));
            }

            /*
             * TemplateService ts = new TemplateService();
             * string dir = ConfigurationManager.AppSettings["PhysicalPath"];
             * string WordDoc = ts.GenerateDocumentFromTemplateName(TemplateDocsID, EventID, ProjectID, dir, ReportPeriodID);
             *
             * TemplateFile tfile = ts.GetTemplateDocument(TemplateDocsID).TemplateFile;
             *
             * string virtdir = "files/A" + DateTime.Now.Year.ToString().Substring(2) + ProjectID.ToString()+"/";
             * dir += virtdir.Replace("/", "\\");
             *
             * if (!(Directory.Exists(dir)))
             * {
             *  Directory.CreateDirectory(dir);
             * }
             * string fileformat=EventID.ToString()+"_"+ProjectID.ToString()+"_";
             * int i;
             * for (i = 1; System.IO.File.Exists(dir+fileformat+i.ToString()+"."+tfile.fileextension); i++)
             * {
             * }
             * System.IO.File.WriteAllText(dir + fileformat + i.ToString() + "." + tfile.fileextension, WordDoc);
             * ProjectEventDocument docItem = new ProjectEventDocument();
             * docItem.Author = session.CurrentUser.FirstName + " " + session.CurrentUser.LastName + " " + session.CurrentUser.MiddleName;;
             * docItem.CreatedDate = DateTime.Now;
             * docItem.fileextension = tfile.fileextension;
             * docItem.FileName = fileformat + i.ToString() + "." + tfile.fileextension;
             * docItem.PhysicalAbsolutePath = dir + fileformat + i.ToString() + "." + tfile.fileextension;
             * docItem.PhysicalVirtualPath = "\\" + virtdir.Replace("/", "\\") + fileformat + i.ToString() + "." + tfile.fileextension;
             * docItem.UpdatedDate = docItem.CreatedDate;
             * docItem.WebVirtualPath = "/" + virtdir + fileformat + i.ToString() + "." + tfile.fileextension;
             * //docItem.
             * ProjectEventService pes = new ProjectEventService();
             * pes.InsertDocument(docItem, EventID);
             *
             *
             * TemplateDocument tdoc=ts.GetTemplateDocument(TemplateDocsID);
             * if (tdoc!=null)
             * {
             *  ProjectService projservice = new ProjectService();
             *
             *  //acknowledgement letter - completed project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("acknowledgement"))
             *  {
             *      AppDropDownsService apservice=new AppDropDownsService();
             *      ProposalStatusList psitem=apservice.ProposalStatusListGetItem("Completed");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *  //award letter - Active project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("award"))
             *  {
             *      AppDropDownsService apservice = new AppDropDownsService();
             *      ProposalStatusList psitem = apservice.ProposalStatusListGetItem("Active");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *  //close out letter - Closed project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("close") && tdoc.TemplateDocName.ToLower().Contains("out"))
             *  {
             *      AppDropDownsService apservice = new AppDropDownsService();
             *      ProposalStatusList psitem = apservice.ProposalStatusListGetItem("Closed");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *  //suspended letter - Active project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("suspended"))
             *  {
             *      AppDropDownsService apservice = new AppDropDownsService();
             *      ProposalStatusList psitem = apservice.ProposalStatusListGetItem("Suspended");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *  //reject letter - Rejected project
             *  if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("reject"))
             *  {
             *      AppDropDownsService apservice = new AppDropDownsService();
             *      ProposalStatusList psitem = apservice.ProposalStatusListGetItem("Rejected");
             *
             *      //if we have needed status in DB then
             *      if (psitem != null)
             *      {
             *          Project _project = projservice.GetProposalInfo(ProjectID);
             *          ProposalStatus _prop = _project.ProposalStatus;
             *          _prop.PropStatusID = psitem.ProposalStatusID;
             *          projservice.ProposalStatusUpdate(_prop);
             *      }
             *
             *  }
             *
             *
             * }*/
            EventTemplate ehelper = new EventTemplate();

            ehelper.CreateFromTemplate(TemplateDocsID, ProjectID, EventID, ReportPeriodID);

            return(RedirectToAction("Index", new { id = EventID }));
        }
        // GET: EventTemplate
        public async Task <IActionResult> Index(EventTemplate eventTemplate = null)
        {
            ViewData["Events"] = await _context.EventTemplates.OrderBy(x => x.SequentialNumber).ToListAsync();

            return(View("Index", eventTemplate ?? new EventTemplate()));
        }
 /// <summary>
 /// 更新事件模板{事件模板}对象(即:一条记录
 /// </summary>
 public int Update(EventTemplate eventTemplate)
 {
     return(Update <EventTemplate>(eventTemplate));
 }
Esempio n. 27
0
        public ServiceResult CreateEventByTemplate(CreateNewEvent newEvent)
        {
            var result = new ServiceResult();

            try
            {
                EventTemplate template = GetEventTemplateById(newEvent.SelectedTemplateId);

                var e = new Event
                {
                    GeneralLocality = newEvent.GeneralLocality,
                    RegionId        = newEvent.RegionId,
                    Place           = template.DefaultPlaceName,
                    IsActive        = false
                };

                int registrationTimeOffset = DirtyGirlServiceConfig.Settings.RegistrationCutoffHours * -1;
                e.RegistrationCutoff = newEvent.EventDate.AddHours(registrationTimeOffset);

                int emailPacketOffset = DirtyGirlServiceConfig.Settings.EmailPacketCutoffDays * -1;
                e.EmailCutoff = newEvent.EventDate.AddDays(emailPacketOffset);

                ServiceResult saveEventResult    = CreateEvent(e);
                ServiceResult generateDateResult = GenerateEventDate(e.EventId, newEvent.EventDate, template.StartTime,
                                                                     template.EndTime, template.WaveDuration,
                                                                     template.MaxRegistrantsPerWave);
                var feeResult = new ServiceResult();

                var rfee = new EventFee
                {
                    EventId       = e.EventId,
                    EffectiveDate = DateTime.Now.Date,
                    Cost          = template.DefaultRegistrationCost,
                    EventFeeType  = EventFeeType.Registration,
                    Discountable  = true,
                    Taxable       = true
                };
                var tFee = new EventFee
                {
                    EventId       = e.EventId,
                    EffectiveDate = DateTime.Now.Date,
                    Cost          = template.DefaultTransferFeeCost,
                    EventFeeType  = EventFeeType.Transfer,
                    Discountable  = false,
                    Taxable       = false
                };
                var chFee = new EventFee
                {
                    EventId       = e.EventId,
                    EffectiveDate = DateTime.Now.Date,
                    Cost          = template.DefaultChangeFeeCost,
                    EventFeeType  = EventFeeType.ChangeEvent,
                    Discountable  = false,
                    Taxable       = false
                };
                var cfee = new EventFee
                {
                    EventId       = e.EventId,
                    EffectiveDate = DateTime.Now.Date,
                    Cost          = template.DefaultCancellationFeeCost,
                    EventFeeType  = EventFeeType.Cancellation,
                    Discountable  = false,
                    Taxable       = false
                };

                var pfee = new EventFee
                {
                    EventId       = e.EventId,
                    EffectiveDate = DateTime.Now.Date,
                    Cost          = template.DefaultProcessingFeeCost,
                    EventFeeType  = EventFeeType.ProcessingFee,
                    Discountable  = false,
                    Taxable       = false
                };

                var sfee = new EventFee
                {
                    EventId       = e.EventId,
                    EffectiveDate = DateTime.Now.Date,
                    Cost          = template.DefaultShippingFeeCost,
                    EventFeeType  = EventFeeType.Shipping,
                    Discountable  = false,
                    Taxable       = false
                };

                CreateEventFee(rfee);
                CreateEventFee(tFee);
                CreateEventFee(chFee);
                CreateEventFee(cfee);
                CreateEventFee(sfee);
                CreateEventFee(pfee);

                foreach (EventTemplate_PayScale ps in template.PayScales)
                {
                    var eventStart = newEvent.EventDate;

                    eventStart = newEvent.EventDate.AddDays(-1 * ps.DaysOut);

                    // for registrations,
                    if (ps.EventFeeType == EventFeeType.Registration)
                    {
                        while (eventStart.DayOfWeek != DayOfWeek.Wednesday)
                        {
                            eventStart = eventStart.AddDays(1);
                        }
                    }
                    var newFee = new EventFee
                    {
                        EventId       = e.EventId,
                        EffectiveDate = eventStart.Date,
                        Cost          = ps.Cost,
                        EventFeeType  = ps.EventFeeType,
                        Taxable       = ps.Taxable,
                        Discountable  = ps.Discountable
                    };

                    feeResult = CreateEventFee(newFee);

                    if (!feeResult.Success)
                    {
                        break;
                    }
                }

                if (saveEventResult.Success && generateDateResult.Success && feeResult.Success)
                {
                    _repository.SaveChanges();
                    newEvent.EventId = e.EventId;
                }
                else
                {
                    result.AddServiceError("An Error Occured Creating this Event");
                }
            }
            catch (Exception ex)
            {
                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }

            return(result);
        }
Esempio n. 28
0
        public static bool RegisterEvent(string name, string template, string feature, string scriptstart, string scriptend, DateTime?startTime, DateTime?endTime, TimeSpan?periodBegin, TimeSpan?periodEnd, string msgstart, string msgnotify, string msgend, int msginterval, int startCont, string username, AdminClientServicePeer peer)
        {
            EventDataContext.StartProcessing();
            EventTemplate eventTemplate = null;
            bool          flag          = false;

            if (EventDataContext.IsRunning(name))
            {
                if (peer != null)
                {
                    string msg = EventDataContext.SendEventListAndDetail(name, "Event is Already Running !", true);
                    peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, msg)));
                }
                return(false);
            }
            if (template != null)
            {
                eventTemplate = AdminContents.GetTemplate(template);
                if (eventTemplate == null)
                {
                    if (peer != null)
                    {
                        peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Cannot Find Event Template ! - \"{0}\"", template))));
                    }
                    return(false);
                }
            }
            Event @event = EventDataContext.GetEvent(name);

            if (@event == null)
            {
                @event      = new Event();
                @event.Name = name;
                flag        = true;
            }
            if (eventTemplate != null)
            {
                @event.Feature     = eventTemplate.Feature;
                @event.StartScript = eventTemplate.StartScript;
                @event.EndScript   = eventTemplate.EndScript;
            }
            if (feature != null)
            {
                @event.Feature = feature;
            }
            if (scriptstart != null)
            {
                @event.StartScript = scriptstart;
            }
            if (scriptend != null)
            {
                @event.EndScript = scriptend;
            }
            if (startTime != null)
            {
                if (startTime < DateTime.Now)
                {
                    if (peer != null)
                    {
                        peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Reservation Time Error - \"{0}\"", startTime))));
                    }
                    return(false);
                }
                @event.StartTime = startTime;
            }
            if (endTime != null)
            {
                if (endTime < DateTime.Now)
                {
                    if (peer != null)
                    {
                        peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Reservation Time Error - \"{0}\"", endTime))));
                    }
                    return(false);
                }
                @event.EndTime = endTime;
            }
            if (periodBegin != null)
            {
                @event.PeriodBegin = periodBegin;
            }
            if (periodEnd != null)
            {
                @event.PeriodEnd = periodEnd;
            }
            if (msgstart != null)
            {
                @event.StartMessage = msgstart;
            }
            if (msgnotify != null)
            {
                @event.NotifyMessage = msgnotify;
            }
            if (msgend != null)
            {
                @event.EndMessage = msgend;
            }
            @event.NotifyInterval = new int?(msginterval);
            @event.StartCount     = new int?(startCont);
            @event.UserName       = username;
            if (flag)
            {
                if (feature != null)
                {
                    string text = EventDataContext.IsExistFeature(feature);
                    if (text != null)
                    {
                        if (peer != null)
                        {
                            peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("That feature is already exist ! - \"{0}\"", text))));
                        }
                        return(false);
                    }
                }
                if (!EventDataContext.AddEvent(@event))
                {
                    if (peer != null)
                    {
                        peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Event Register Failed ! - \"{0}\"", name))));
                    }
                    return(false);
                }
            }
            else if (!EventDataContext.ModifyEvent(@event))
            {
                if (peer != null)
                {
                    peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Event Update Failed ! - \"{0}\"", name))));
                }
                return(false);
            }
            if (@event.StartTime == null && !(@event.StartCount > 0))
            {
                EventDataContext.StartEvent(name, @event);
                if (peer != null)
                {
                    string msg2 = EventDataContext.SendEventListAndDetail(name, "Event is Started !", true);
                    peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, msg2)));
                }
            }
            else if (peer != null)
            {
                string msg3 = EventDataContext.SendEventListAndDetail(name, "Event is Reserved !", true);
                peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, msg3)));
            }
            return(true);
        }
Esempio n. 29
0
 public EventOccurredInfo(IResource resource, EventTemplate eventTemplate, object value)
 {
     Resource      = resource;
     Value         = value;
     EventTemplate = eventTemplate;
 }
Esempio n. 30
0
 public Event(EventTemplate t)
 {
     Template   = t;
     TurnNumber = Galaxy.Current.TurnNumber + Template.TimeTillCompletion.Value;
     Dice       = new PRNG(GetHashCode());
 }