コード例 #1
0
ファイル: CswDateTimeTest.cs プロジェクト: crfroehlich/legacy
        public void XmlDateFormatTest()
        {
            string      d1  = "2012-11-06T09:30:15.1234";
            CswDateTime cd1 = new CswDateTime(_CswResources);

            cd1.FromXmlDateTimeFormat(d1);
            Assert.IsTrue(_checkDateTimeParts(cd1.ToDateTime(), 2012, 11, 6, 9, 30, 15, 123));

            string      d2  = "1970-01-01T00:00:00";
            CswDateTime cd2 = new CswDateTime(_CswResources);

            cd2.FromXmlDateTimeFormat(d2);
            Assert.IsTrue(_checkDateTimeParts(cd2.ToDateTime(), 1970, 1, 1, 0, 0, 0, 0));

            string      d3  = "1970-01-01T00:00:00.0000";
            CswDateTime cd3 = new CswDateTime(_CswResources);

            cd3.FromXmlDateTimeFormat(d3);
            Assert.IsTrue(_checkDateTimeParts(cd3.ToDateTime(), 1970, 1, 1, 0, 0, 0, 0));

            string      d4  = "2099-02-28T18:24:48";
            CswDateTime cd4 = new CswDateTime(_CswResources);

            cd4.FromXmlDateTimeFormat(d4);
            Assert.IsTrue(_checkDateTimeParts(cd4.ToDateTime(), 2099, 2, 28, 18, 24, 48, 0));
        } // XmlDateFormatTest()
コード例 #2
0
        public IEnumerable<CswNbtMetaDataNodeTypeProp> getLayoutProps( Int32 NodeTypeId, Int32 TabId, CswEnumNbtLayoutType LayoutType, CswDateTime Date, bool PropsInLayout = true )
        {
            string NodeTypeIdStr = NodeTypeId.ToString();
            string WhereClause = "where nodetypeid = '" + NodeTypeIdStr + "' ";
            WhereClause += " and nodetypepropid ";
            if( PropsInLayout )
            {
                WhereClause += " in ";
            }
            else
            {
                WhereClause += " not in ";
            }
            WhereClause += " (select nodetypepropid ";
            if( null == Date || Date.ToDateTime() == DateTime.MinValue )
            {
                WhereClause += " from nodetype_layout ";
            }
            else
            {
                WhereClause += " from " + CswNbtAuditTableAbbreviation.getAuditTableSql( _CswNbtMetaDataResources.CswNbtResources, "nodetype_layout", Date );
            }
            WhereClause += " where layouttype = '" + LayoutType.ToString() + "'" +
                           "   and nodetypeid = " + NodeTypeIdStr + @" ";
            if( LayoutType == CswEnumNbtLayoutType.Edit && TabId != Int32.MinValue )
            {
                WhereClause += "and nodetypetabsetid = " + TabId.ToString();
            }
            WhereClause += ")";

            return _CollImpl.getWhere( WhereClause, Date ).Cast<CswNbtMetaDataNodeTypeProp>();

        } // getPropsInLayout()
コード例 #3
0
        public override void ReadJSON(JObject JObject, Dictionary <Int32, Int32> NodeMap, Dictionary <Int32, Int32> NodeTypeMap)
        {
            if (DateAnswered == DateTime.MinValue)
            {
                CswDateTime CswDateAnswered = new CswDateTime(_CswNbtResources);
                CswDateAnswered.FromClientDateTimeJObject((JObject)JObject[_DateAnsweredSubField.ToXmlNodeName(true)]);
                DateAnswered = CswDateAnswered.ToDateTime();
            }
            if (DateCorrected == DateTime.MinValue)
            {
                CswDateTime CswDateCorrected = new CswDateTime(_CswNbtResources);
                CswDateCorrected.FromClientDateTimeJObject((JObject)JObject[_DateCorrectedSubField.ToXmlNodeName(true)]);
                DateCorrected = CswDateCorrected.ToDateTime();
            }

            if (null != JObject[_AnswerSubField.ToXmlNodeName(true)] && IsAnswerEditable)
            {
                Answer = JObject[_AnswerSubField.ToXmlNodeName(true)].ToString();
            }
            if (null != JObject[_CommentsSubField.ToXmlNodeName(true)])
            {
                Comments = JObject[_CommentsSubField.ToXmlNodeName(true)].ToString();
            }
            if (null != JObject[_CorrectiveActionSubField.ToXmlNodeName(true)])
            {
                CorrectiveAction = JObject[_CorrectiveActionSubField.ToXmlNodeName(true)].ToString();
            }
        }
コード例 #4
0
        public override void ReadJSON(JObject JObject, Dictionary <Int32, Int32> NodeMap, Dictionary <Int32, Int32> NodeTypeMap)
        {
            if (null != JObject[_DateValueSubField.ToXmlNodeName(true)])
            {
                //DateValue = CswConvert.ToDateTime( JObject.Property( _DateValueSubField.ToXmlNodeName(true) ).Value );
                //DateValue = CswConvert.ToDateTime( JObject.Property( _DateValueSubField.ToXmlNodeName( true ) ).Value );

                CswDateTime CswDate = new CswDateTime(_CswNbtResources);
                CswDate.FromClientDateTimeJObject((JObject)JObject[_DateValueSubField.ToXmlNodeName(true)]);
                DateTimeValue = CswDate.ToDateTime();
            }
        }
コード例 #5
0
 public override void ReadJSON(JObject JObject, Dictionary <Int32, Int32> NodeMap, Dictionary <Int32, Int32> NodeTypeMap)
 {
     if (null != JObject[_StartDateTimeSubField.ToXmlNodeName(true)])
     {
         //StartDateTime = CswConvert.ToDateTime( JObject.Property( _StartDateTimeSubField.ToXmlNodeName( true ) ).Value );
         CswDateTime CswDate = new CswDateTime(_CswNbtResources);
         CswDate.FromClientDateTimeJObject((JObject)JObject[_StartDateTimeSubField.ToXmlNodeName(true)]);
         StartDateTime = CswDate.ToDateTime();
     }
     if (null != JObject[_UnitsSubField.ToXmlNodeName(true)])
     {
         Units = JObject[_UnitsSubField.ToXmlNodeName(true)].ToString();
     }
     //PendingUpdate = true;
     RefreshCachedValue();
 }
コード例 #6
0
 public static string getAuditTableSql(CswNbtResources CswNbtResources, string RealTableName, CswDateTime Date, Int32 NodeId = Int32.MinValue)
 {
     return(getAuditTableSql(CswNbtResources, RealTableName, Date.ToDateTime(), NodeId));
 }
コード例 #7
0
        public JObject makeVersionJson(CswSessionResourcesNbt _CswSessionResources)
        {
            JObject ret = new JObject();

            string AssemblyFilePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "/_Assembly.txt";

            if (File.Exists(AssemblyFilePath))
            {
                TextReader AssemblyFileReader = new StreamReader(AssemblyFilePath);
                ret.Add(new JProperty("assembly", AssemblyFileReader.ReadLine()));
                AssemblyFileReader.Close();
            }

            JObject   ComponentObj   = new JObject();
            JProperty ComponentsProp = new JProperty("components", ComponentObj);

            ret.Add(ComponentsProp);
            string ThisYear = DateTime.Now.Year.ToString();

            ArrayList CswAssemblies = new ArrayList();

            CswAssemblies.Add("NbtWebApp");
            CswAssemblies.Add("CswCommon");
            CswAssemblies.Add("CswWebControls");
            CswAssemblies.Add("NbtLogic");
            CswAssemblies.Add("NbtWebControls");

            foreach (string AssemblyName in CswAssemblies)
            {
                string name = AssemblyName.Contains(",") ? AssemblyName.Substring(0, AssemblyName.IndexOf(',')) : AssemblyName;

                JObject AssemObj = new JObject();
                ComponentObj.Add(new JProperty(name, AssemObj));

                Assembly AssemblyInfo = Assembly.Load(AssemblyName);
                string   Version      = AssemblyInfo.GetName().Version.ToString();
                AssemObj.Add(new JProperty("name", name));
                AssemObj.Add(new JProperty("version", Version));
                AssemObj.Add(new JProperty("copyright", "Copyright &copy; ChemSW, Inc. 2005-" + ThisYear));
            }

            ArrayList ThirdAssemblies = new ArrayList();

            ThirdAssemblies.Add("CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304");
            ThirdAssemblies.Add("Telerik.Web.UI");

            foreach (string AssemblyName in ThirdAssemblies)
            {
                string name = AssemblyName.Contains(",") ? AssemblyName.Substring(0, AssemblyName.IndexOf(',')) : AssemblyName;

                JObject AssemObj = new JObject();
                ComponentObj.Add(new JProperty(name, AssemObj));

                Assembly AssemblyInfo       = Assembly.Load(AssemblyName);
                object[] AssemblyAttributes = (object[])AssemblyInfo.GetCustomAttributes(true);

                string Version   = AssemblyInfo.GetName().Version.ToString();
                string Copyright = string.Empty;
                foreach (AssemblyCopyrightAttribute AssemblyAttribute in AssemblyAttributes.OfType <AssemblyCopyrightAttribute>())
                {
                    Copyright = (AssemblyAttribute).Copyright;
                }
                AssemObj.Add(new JProperty("name", name));
                AssemObj.Add(new JProperty("version", Version));
                AssemObj.Add(new JProperty("copyright", Copyright));
            }

            ComponentObj.Add(new JProperty("Schema",
                                           new JObject(
                                               new JProperty("name", "Schema"),
                                               new JProperty("version", _CswNbtResources.ConfigVbls.getConfigVariableValue("schemaversion")),
                                               new JProperty("copyright", "Copyright &copy; ChemSW, Inc. 2005-" + ThisYear)
                                               )

                                           ));

            #region ChemCatCentral Products Versions
            // Add ChemCatCentral version to the About dialog: Case 29380
            if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.C3Products))
            {
                CswC3Params           CswC3Params     = new CswC3Params();
                CswNbtC3ClientManager C3ClientManager = new CswNbtC3ClientManager(_CswNbtResources, CswC3Params);
                SearchClient          C3SearchClient  = C3ClientManager.initializeC3Client();
                if (null != C3SearchClient)
                {
                    string C3Version = C3ClientManager.getCurrentC3Version();
                    ComponentObj.Add(new JProperty("ChemCatCentral", new JObject(
                                                       new JProperty("name", "ChemCatCentral"),
                                                       new JProperty("version", Regex.Replace(C3Version, "_", " ")),
                                                       new JProperty("copyright", "Copyright &copy; ChemSW, Inc. 2005-" + ThisYear))));

                    // Add the datasource import dates (if they are available to the user and/or the module is enabled
                    CswC3ServiceLogicGetDataSourcesDataSource[] DataSourceDates = C3ClientManager.getDataSourceDates();
                    if (null != DataSourceDates)
                    {
                        JObject DSDatesObj = new JObject();
                        foreach (CswC3ServiceLogicGetDataSourcesDataSource ds in DataSourceDates)
                        {
                            if (ds.DataType == "Extra Chemical")
                            {
                                switch (ds.DataSourceName)
                                {
                                case "FireDb":
                                    if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.FireDbSync))
                                    {
                                        DSDatesObj[ds.DataSourceName] = new JObject(new JProperty("componentName", ds.DataSourceName), new JProperty("value", ds.ImportDate));
                                    }
                                    break;

                                case "PCID":
                                    if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.PCIDSync))
                                    {
                                        DSDatesObj[ds.DataSourceName] = new JObject(new JProperty("componentName", ds.DataSourceName), new JProperty("value", ds.ImportDate));
                                    }
                                    break;
                                } //switch
                            }
                            else
                            {
                                DSDatesObj[ds.DataSourceName] = new JObject(new JProperty("componentName", ds.DataSourceName), new JProperty("value", ds.ImportDate));
                            }
                        }
                        ret.Add(new JProperty("dsDates", DSDatesObj));
                    }
                }//if( C3ClientManager.checkC3ServiceReferenceStatus() )
            }
            #endregion ChemCatCentral Products Versions

            #region ACD Version
            if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.C3ACD))
            {
                CswC3Params           CswC3Params     = new CswC3Params();
                CswNbtC3ClientManager C3ClientManager = new CswNbtC3ClientManager(_CswNbtResources, CswC3Params);
                SearchClient          C3SearchClient  = C3ClientManager.initializeC3Client();
                if (null != C3SearchClient)
                {
                    CswRetObjSearchResults Results = C3SearchClient.getACDVersion(CswC3Params);
                    if (null != Results)
                    {
                        ComponentObj.Add(new JProperty("ACD", new JObject(
                                                           new JProperty("name", "Available Chemicals Directory (ACD)"),
                                                           new JProperty("version", Regex.Replace(Results.ACDVersion, "_", " ")),
                                                           new JProperty("copyright", "Copyright &copy; Accelrys, Inc. 1983-" + ThisYear))));
                    }
                }
            }
            #endregion ACD Version


            SortedList <string, CswSessionsListEntry> sessions = _CswSessionResources.CswSessionManager.SessionsList.AllSessions;
            CswDateTime loginDate = new CswDateTime(_CswNbtResources);
            foreach (var entry in sessions)
            {
                CswSessionsListEntry sessionEntry = entry.Value;
                if (sessionEntry.UserName.Equals(_CswNbtResources.CurrentUser.Username))
                {
                    loginDate.FromClientDateString(sessionEntry.LoginDate.ToString());
                }
            }

            JObject UserObj = new JObject();
            UserObj["customerid"]   = new JObject(new JProperty("componentName", "Customer ID:"), new JProperty("value", _CswNbtResources.AccessId));
            UserObj["loggedinas"]   = new JObject(new JProperty("componentName", "Logged in as:"), new JProperty("value", _CswNbtResources.CurrentUser.Username));
            UserObj["sessionsince"] = new JObject(new JProperty("componentName", "Session since:"), new JProperty("value", loginDate.ToDateTime().ToString()));

            ret.Add(new JProperty("userProps", UserObj));

            return(ret);
        } // makeVersionJson()