public async Task <components> GenerateComponent(components _components)
        {
            await _context.Components.AddAsync(_components);

            await _context.SaveChangesAsync();

            return(_components);
        }
Ejemplo n.º 2
0
        // ADD
        public static bool AddComponent(components c)
        {
            Context.components.Add(c);
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateException dbEx)
            {
                return false;
            }
            catch (DbEntityValidationException ex)
            {
                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry

                    DbEntityEntry entry = item.Entry;
                    string entityTypeName = entry.Entity.GetType().Name;

                    // Display or log error messages

                    foreach (DbValidationError subItem in item.ValidationErrors)
                    {
                        string message = string.Format("Error '{0}' occurred in {1} at {2}",
                                 subItem.ErrorMessage, entityTypeName, subItem.PropertyName);
                        Console.WriteLine(message);
                    }
                    // Rollback changes

                    switch (entry.State)
                    {
                        case EntityState.Added:
                            entry.State = EntityState.Detached;
                            break;
                        case EntityState.Modified:
                            entry.CurrentValues.SetValues(entry.OriginalValues);
                            entry.State = EntityState.Unchanged;
                            break;
                        case EntityState.Deleted:
                            entry.State = EntityState.Unchanged;
                            break;
                    }
                }
                return false;
            }
            Context.Entry(c).Reload();
            return true;
        }
Ejemplo n.º 3
0
        // DELETE
        public static bool DeleteComponent(components c)
        {
            components componentToDelete = GetComponentById(c.Id);

            componentToDelete.IsDeleted = true;

            int affectedRows;
            try
            {
                affectedRows = Context.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry

                    DbEntityEntry entry = item.Entry;
                    string entityTypeName = entry.Entity.GetType().Name;

                    // Display or log error messages

                    foreach (DbValidationError subItem in item.ValidationErrors)
                    {
                        string message = string.Format("Error '{0}' occurred in {1} at {2}",
                                 subItem.ErrorMessage, entityTypeName, subItem.PropertyName);
                        Console.WriteLine(message);
                    }
                    // Rollback changes

                    switch (entry.State)
                    {
                        case EntityState.Added:
                            entry.State = EntityState.Detached;
                            break;
                        case EntityState.Modified:
                            entry.CurrentValues.SetValues(entry.OriginalValues);
                            entry.State = EntityState.Unchanged;
                            break;
                        case EntityState.Deleted:
                            entry.State = EntityState.Unchanged;
                            break;
                    }
                }
                return false;
            }
            return affectedRows > 0;
        }
Ejemplo n.º 4
0
        protected void AddControl_OnClick(object sender, EventArgs e)
        {
            components newComponent = new components();

            int oNo;
            newComponent.webpages_Id = int.Parse(HiddenFieldWebPageId.Value);
            newComponent.OrderingNumber = int.TryParse(tbAddOrderingNumber.Text, out oNo) ? oNo : 1;
            newComponent.controls_Id = int.Parse(ddlAddComControls.SelectedValue);

            if (ComponentDB.AddComponent(newComponent))
            {
                ActionStatusComponentsList.Text = "New component has successfully been added!";
                ActionStatusComponentsList.ForeColor = Color.CornflowerBlue;

                controls c = ControlDB.GetControlsById(newComponent.controls_Id);
                var filterTypeNameList = new List<string>();
                if (c != null)
                {
                    //EventHandlingSystem.Components.
                    Type cls = Type.GetType("EventHandlingSystem.Components."+c.Name);
                    if (cls != null)
                    {
                        foreach (var prop in cls.GetProperties())
                        {
                            filterTypeNameList.Add(prop.Name);
                        }
                    }
                }
                ActionStatusComponentsList.Text += "<br/>FilterData added:";
                foreach (var type in filterTypeNameList)
                {
                    filterdata newFilterData = new filterdata {Type = type, Components_Id = newComponent.Id, Data = ""};
                    if (FilterDataDB.AddFilterData(newFilterData))
                    {
                        ActionStatusComponentsList.Text += " " + newFilterData.Type + "=\""+ newFilterData.Data+"\"";
                    }
                }
            }
            else
            {
                ActionStatusComponentsList.Text = "Sorry! New component was not added.";
                ActionStatusComponentsList.ForeColor = Color.Red;
            }
            PopulateDropDownListControls();
            DisplayComponentsForWebPage();
        }
        public ActionResult CodeAdd(RequestFormInfo formInfo, int bl, int kj, int qj, int mr, int jssx, int ff)
        {
            //遍历自定义变量并放入集合
            List <definition> bianlianglist = new List <definition>();

            for (int i = 1; i <= bl; i++)
            {
                string desc    = Request.Form["bldesc" + i];
                string content = Request.Form["bl" + i];
                if (!string.IsNullOrWhiteSpace(desc) && !string.IsNullOrWhiteSpace(content))
                {
                    definition definition = new definition()
                    {
                        desc    = desc,
                        content = content
                    };
                    bianlianglist.Add(definition);
                }
            }

            //遍历控件部件并放入集合
            List <components> kongjianList = new List <components>();

            for (int i = 1; i <= kj; i++)
            {
                string desc    = Request.Form["kjdesc" + i];
                string content = Request.Form["kj" + i];
                if (!string.IsNullOrWhiteSpace(desc) && !string.IsNullOrWhiteSpace(content))
                {
                    components components = new components()
                    {
                        desc    = desc,
                        content = content
                    };
                    kongjianList.Add(components);
                }
            }

            //遍历全局变量并放入集合
            List <data> quanjuList = new List <data>();

            for (int i = 1; i <= qj; i++)
            {
                string content = Request.Form["qjdesc" + i];
                string desc    = Request.Form["qj" + i];
                if (!string.IsNullOrWhiteSpace(content) && !string.IsNullOrWhiteSpace(desc))
                {
                    data data = new data()
                    {
                        content = content,
                        desc    = desc
                    };
                    quanjuList.Add(data);
                }
            }

            //遍历默认数据并放入集合
            List <@default> morenList = new List <@default>();

            for (int i = 1; i <= mr; i++)
            {
                string desc  = Request.Form["mrdesc" + i];
                string key   = Request.Form["mrkey" + i];
                string value = Request.Form["mrvalue" + i];
                if (!string.IsNullOrWhiteSpace(desc) && !string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(value))
                {
                    @default @default = new @default()
                    {
                        desc  = desc,
                        key   = key,
                        value = value
                    };
                    morenList.Add(@default);
                }
            }

            //遍历计算属性并放入集合
            List <computed> jssxList = new List <computed>();

            for (int i = 1; i <= jssx; i++)
            {
                string jssxname = Request.Form["jssxname" + i];
                string jssxdesc = Request.Form["jssxdesc" + i];
                string jssxff   = Request.Form["jssxff" + i];
                if (!string.IsNullOrWhiteSpace(jssxname) && !string.IsNullOrWhiteSpace(jssxdesc) && !string.IsNullOrWhiteSpace(jssxff))
                {
                    computed computed = new computed()
                    {
                        desc    = jssxdesc,
                        name    = jssxname,
                        content = jssxff
                    };
                    jssxList.Add(computed);
                }
            }

            //遍历控件方法并放入集合
            List <rests> qtfangfaList = new List <rests>();

            for (int i = 1; i <= ff; i++)
            {
                string qtffname = Request.Form["qtffname" + i];
                string qtffdesc = Request.Form["qtffdesc" + i];
                string qtffti   = Request.Form["qtffti" + i];
                if (!string.IsNullOrWhiteSpace(qtffname) && !string.IsNullOrWhiteSpace(qtffdesc) && !string.IsNullOrWhiteSpace(qtffti))
                {
                    rests rests = new rests()
                    {
                        name    = qtffname,
                        desc    = qtffdesc,
                        content = qtffti
                    };
                    qtfangfaList.Add(rests);
                }
            }

            //遍历控件方法并放入集合
            List <methods> fangfaList = new List <methods>();

            for (int i = 1; i <= ff; i++)
            {
                string ffname = Request.Form["ffname" + i];
                string ffdesc = Request.Form["ffdesc" + i];
                string ffti   = Request.Form["ffti" + i];
                if (!string.IsNullOrWhiteSpace(ffname) && !string.IsNullOrWhiteSpace(ffdesc) && !string.IsNullOrWhiteSpace(ffti))
                {
                    methods methods = new methods()
                    {
                        name    = ffname,
                        desc    = ffdesc,
                        content = ffti
                    };
                    fangfaList.Add(methods);
                }
            }


            //调用方法开始进行数据库存储
            //实例化代码入库类
            CodeDataBase codeInDataBase = new CodeDataBase();
            int          result         = codeInDataBase.AddCodeInBase(formInfo, bianlianglist, kongjianList, quanjuList, morenList, jssxList, qtfangfaList, fangfaList);

            switch (result)
            {
            case 0:
                return(Json(new { code = 1, msg = "代码入库失败!" }, JsonRequestBehavior.AllowGet));

            case 1:
                return(Json(new { code = 1, msg = "代码入库成功!" }, JsonRequestBehavior.AllowGet));

            case 2:
                return(Json(new { code = 1, msg = "html代码入库失败!" }, JsonRequestBehavior.AllowGet));

            case 3:
                return(Json(new { code = 1, msg = "Css样式入库失败!" }, JsonRequestBehavior.AllowGet));

            case 4:
                return(Json(new { code = 1, msg = "自定义变量入库失败!" }, JsonRequestBehavior.AllowGet));

            case 5:
                return(Json(new { code = 1, msg = "控件部件入库失败!" }, JsonRequestBehavior.AllowGet));

            case 6:
                return(Json(new { code = 1, msg = "全局变量入库失败!" }, JsonRequestBehavior.AllowGet));

            case 7:
                return(Json(new { code = 1, msg = "默认数据入库失败!" }, JsonRequestBehavior.AllowGet));

            case 8:
                return(Json(new { code = 1, msg = "计算属性入库失败!" }, JsonRequestBehavior.AllowGet));

            case 9:
                return(Json(new { code = 1, msg = "控件方法入库失败!" }, JsonRequestBehavior.AllowGet));

            case 10:
                return(Json(new { code = 1, msg = "添加到PageShow页面失败!" }, JsonRequestBehavior.AllowGet));
            }



            return(View());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Create OpenDoPE parts, including optionally, question part.
        /// </summary>
        public void process()
        {
            Microsoft.Office.Interop.Word.Document document = null;
            try
            {
                document = Globals.ThisAddIn.Application.ActiveDocument;
            }
            catch (Exception ex)
            {
                Mbox.ShowSimpleMsgBoxError("No document is open/active. Create or open a docx first.");
                return;
            }

            Model model = Model.ModelFactory(document);

            // Button shouldn't be available if this exists,
            // but ..
            if (model.conditionsPart == null)
            {
                conditions conditions    = new conditions();
                string     conditionsXml = conditions.Serialize();
                model.conditionsPart = addCustomXmlPart(document, conditionsXml);
            }

            if (model.componentsPart == null)
            {
                components components    = new components();
                string     componentsXml = components.Serialize();
                model.componentsPart = addCustomXmlPart(document, componentsXml);
            }

            // Add XPath
            xpaths xpaths = new xpaths();

            // Button shouldn't be available if this exists,
            // but ..
            if (model.xpathsPart != null)
            {
                xpaths.Deserialize(model.xpathsPart.XML, out xpaths);
            }
            int idInt = 1;

            foreach (Word.ContentControl cc in Globals.ThisAddIn.Application.ActiveDocument.ContentControls)
            {
                if (cc.XMLMapping.IsMapped)
                {
                    log.Debug("Adding xpath for " + cc.ID);
                    // then we need to add an XPath
                    string xmXpath = cc.XMLMapping.XPath;

                    xpathsXpath item = new xpathsXpath();
                    // I make no effort here to check whether the xpath
                    // already exists, since the part shouldn't already exist!

                    item.id = "x" + idInt;


                    xpathsXpathDataBinding db = new xpathsXpathDataBinding();
                    db.xpath       = xmXpath;
                    db.storeItemID = cc.XMLMapping.CustomXMLPart.Id;
                    if (!string.IsNullOrWhiteSpace(cc.XMLMapping.PrefixMappings))
                    {
                        db.prefixMappings = cc.XMLMapping.PrefixMappings;
                    }
                    item.dataBinding = db;

                    xpaths.xpath.Add(item);

                    // Write tag
                    TagData td = new TagData(cc.Tag);
                    td.set("od:xpath", item.id);
                    cc.Tag = td.asQueryString();

                    log.Debug(".. added for " + cc.ID);
                    idInt++;
                }
            }
            string xpathsXml = xpaths.Serialize();

            if (model.xpathsPart == null)
            {
                model.xpathsPart = addCustomXmlPart(document, xpathsXml);
            }
            else
            {
                CustomXmlUtilities.replaceXmlDoc(model.xpathsPart, xpathsXml);
            }


            Microsoft.Office.Tools.Word.Document extendedDocument
                = Globals.ThisAddIn.Application.ActiveDocument.GetVstoObject(Globals.Factory);

            //Microsoft.Office.Tools.CustomTaskPane ctp
            //    = Globals.ThisAddIn.createCTP(document, cxp, xpathsPart, conditionsPart, questionsPart, componentsPart);
            //extendedDocument.Tag = ctp;
            //// Want a 2 way association
            //WedTaskPane wedTaskPane = (WedTaskPane)ctp.Control;
            //wedTaskPane.associatedDocument = document;

            //extendedDocument.Shutdown += new EventHandler(
            //    Globals.ThisAddIn.extendedDocument_Shutdown);

            //taskPane.setupCcEvents(document);

            log.Debug("Done. Task pane now also open.");
        }
Ejemplo n.º 7
0
 public static extern Boolean GetFileTime(IntPtr hFile, components.Shared.Structures.FILETIME lpCreationTime,
     out components.Shared.Structures.FILETIME lpLastAccessTime, out components.Shared.Structures.FILETIME lpLastWriteTime);
Ejemplo n.º 8
0
 public static extern Boolean FileTimeToSystemTime(ref components.Shared.Structures.FILETIME lpFileTime, 
     out SYSTEMTIME lpSystemTime);
Ejemplo n.º 9
0
 public static extern Boolean FileTimeToLocalFileTime(ref components.Shared.Structures.FILETIME lpFileTime,
     out components.Shared.Structures.FILETIME lpLocalFileTime);
Ejemplo n.º 10
0
 public static extern Int64 CompareFileTime(ref components.Shared.Structures.FILETIME lpFileTime1,
     ref components.Shared.Structures.FILETIME lpFileTime2);
Ejemplo n.º 11
0
 If Not (components Is Nothing) Then
Ejemplo n.º 12
0
        // UPDATE
        public static int UpdateComponent(components c)
        {
            components componentToUpdate = GetComponentById(c.Id);

            componentToUpdate.OrderingNumber = c.OrderingNumber;
            componentToUpdate.filterdata = c.filterdata;
            componentToUpdate.controls_Id = c.controls_Id;
            componentToUpdate.webpages_Id = c.webpages_Id;

            int affectedRows;

            try
            {
                affectedRows = Context.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry

                    DbEntityEntry entry = item.Entry;
                    string entityTypeName = entry.Entity.GetType().Name;

                    // Display or log error messages

                    foreach (DbValidationError subItem in item.ValidationErrors)
                    {
                        string message = string.Format("Error '{0}' occurred in {1} at {2}",
                                 subItem.ErrorMessage, entityTypeName, subItem.PropertyName);
                        Console.WriteLine(message);
                    }
                    // Rollback changes

                    switch (entry.State)
                    {
                        case EntityState.Added:
                            entry.State = EntityState.Detached;
                            break;
                        case EntityState.Modified:
                            entry.CurrentValues.SetValues(entry.OriginalValues);
                            entry.State = EntityState.Unchanged;
                            break;
                        case EntityState.Deleted:
                            entry.State = EntityState.Unchanged;
                            break;
                    }
                }
                return affectedRows = 0;
            }
            Context.Entry(componentToUpdate).Reload();
            return affectedRows;
        }
Ejemplo n.º 13
0
        /* strong typed data objects */
        public DataSet GetDataSet(components.Shared.Enums.Enu_SourceEnums.pdDataItemType dataType)
        {
            DataSet ds = new DataSet();

            foreach (KeyValuePair<string, DataSourceItem> de in this.storage)
                if (dataType == de.Value.SourceType || dataType == components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Any)
                    ds.Tables.Add(de.Value.Source);

            return ds;
        }
Ejemplo n.º 14
0
 public void Truncate(components.Shared.Enums.Enu_SourceEnums.pdDataItemType dataType)
 {
     foreach (KeyValuePair<string, DataSourceItem> de in this.storage)
         if (dataType == de.Value.SourceType || dataType == components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Any)
             this.storage[de.Key] = new DataSourceItem();
 }
Ejemplo n.º 15
0
        public static void UpdateSource(Com_HashObject source, ref components.Components.DataContainer.DataContainer dc)
        {
            Dictionary<components.Shared.Enums.Enu_SourceEnums.pdDataItemType, DataTableCreateMethod> dTCreator = new Dictionary<components.Shared.Enums.Enu_SourceEnums.pdDataItemType, DataTableCreateMethod>();
            Dictionary<components.Shared.Enums.Enu_SourceEnums.pdDataItemType, DataSourceReader> dSReader = new Dictionary<components.Shared.Enums.Enu_SourceEnums.pdDataItemType, DataSourceReader>();

            // data table creators
            dTCreator[components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Product] = CreateDataTableForProduct;
            dTCreator[components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Alternative] = CreateDataTableForAlternative;
            dTCreator[components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Client] = CreateDataTableForCard;
            dTCreator[components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Order] = CreateDataTableForOrder;

            // source readers
            dSReader[components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Product] = ReadProduct;
            dSReader[components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Alternative] = ReadAlternative;
            dSReader[components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Client] = ReadCard;
            // order reader is not implemented because of ugc.

            // steps to load data
            // 1. load new data or load existed
            // 2. create data sources
            // 3. fill data sources with loaded data

            DataSourceItem dSrcItem = new DataSourceItem();

            DataTable __tempDataTable = new DataTable();
            bool fOK = false;

            string __tempFilePath = string.Empty;

            // loop by profiles
            // [foreach 1 - profile]
            foreach (DictionaryEntry profileEntry in source)
            {
                foreach (KeyValuePair<components.Shared.Enums.Enu_SourceEnums.pdDataItemType, DataSourceReader> currentSourceReader in dSReader)
                {
                    // create data table
                    __tempDataTable = dTCreator[currentSourceReader.Key].Invoke();
                    __tempDataTable.TableName = string.Format("{0}_{1:D2}", currentSourceReader.Key, int.Parse(profileEntry.Key.ToString()));

                    //dSrcItem = new DataSourceItem(dTCreator[currentSourceReader.Key].Invoke(), currentSourceReader.Key.ToString());

                    // if there is remote file
                    // we'll copy and load it
                    if (!source[profileEntry.Key][CoreConst.SOURCE_REMOTE].GetValue(currentSourceReader.Key).ToString().Equals(string.Empty))
                    {
                        Com_WinApi.OutputDebugString("copy start");
                        __tempFilePath = source[profileEntry.Key][CoreConst.SOURCE_TEMP].GetValue(currentSourceReader.Key).ToString();
                        fOK = Com_WinApi.CopyFile(source[profileEntry.Key][CoreConst.SOURCE_REMOTE].GetValue(currentSourceReader.Key).ToString(), __tempFilePath, false);
                        Com_WinApi.OutputDebugString("copy end");
                        if (fOK && Com_WinApi.PathFileExists(__tempFilePath))
                        {
                            dSReader[currentSourceReader.Key].Invoke(__tempFilePath, ref __tempDataTable, int.Parse(profileEntry.Key.ToString()));
                            __tempDataTable.WriteXml(source[profileEntry.Key][CoreConst.SOURCE_LOCAL].GetValue(currentSourceReader.Key).ToString());
                        }
                        try
                        {
                            Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(__tempFilePath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
                        }
                        catch { }
                    }
                    else // check if there is local file we'll load it
                    {
                        __tempFilePath = source[profileEntry.Key][CoreConst.SOURCE_LOCAL].GetValue(currentSourceReader.Key).ToString();
                        if (Com_WinApi.PathFileExists(__tempFilePath)) try
                            {
                                dSrcItem.Source.ReadXml(__tempFilePath);
                            }
                            catch { }
                    }

                    dSrcItem = new DataSourceItem(__tempDataTable);
                    dc.Storages.Add(dSrcItem);
                }

                // ugc

                __tempDataTable = dTCreator[components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Order].Invoke();
                __tempDataTable.TableName = string.Format("{0}_{1:D2}", components.Shared.Enums.Enu_SourceEnums.pdDataItemType.Order, int.Parse(profileEntry.Key.ToString()));
                dSrcItem = new DataSourceItem(__tempDataTable);
                dSrcItem.Properties = DataWorkShared.GetStandartOrderInfoStructure2();
                dc.Storages.Add(dSrcItem);

            }// end of [foreach 1 - profile]
        }