コード例 #1
0
 public void Add(DataSourceItem ds)
 {
     if (this.storage.ContainsKey(ds.Name))
         this.storage[ds.Name] = ds;
     else
         this.storage.Add(ds.Name, ds);
 }
コード例 #2
0
 public void Add(DataSourceItem ds)
 {
     if (this.storage.ContainsKey(ds.Name))
     {
         this.storage[ds.Name] = ds;
     }
     else
     {
         this.storage.Add(ds.Name, ds);
     }
 }
コード例 #3
0
        public void Add(DataTable dt)
        {
            DataSourceItem dsi = new DataSourceItem(dt);

            this.storage.Add(dsi.Name, dsi);
        }
コード例 #4
0
 public void AddRange(DataSourceItem[] ds)
 {
     foreach (DataSourceItem dsi in ds)
         Add(dsi);
 }
コード例 #5
0
        public void Add(DataTable dt)
        {
            DataSourceItem dsi = new DataSourceItem(dt);

            this.storage.Add(dsi.Name, dsi);
        }
コード例 #6
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]
        }